Heroku Python Web 进程未能在 60 秒内绑定到 $PORT - 不是很明显
Heroku Python Web process failed to bind to $PORT within 60 seconds - not the obvious
好的,以前用简单的解决方案回答了类似的问题。不要认为这是一样的。首先是我的代码然后是日志。我正在使用提供的 PORT 环境变量,但我仍然收到此错误。
if __name__ == "__main__":
import sys
print( 'HELLO %s' % str(sys.argv[1]))
#import os
import os
port = os.environ['PORT']
print(port)
cherrypy.config.update({
'server.socket_port': int(port),
})
cherrypy.quickstart(House())
日志来了
2016-06-28T20:23:08.801989+00:00 app[web.1]: HELLO 33860
2016-06-28T20:23:08.802004+00:00 app[web.1]: 33860
2016-06-28T20:23:08.802471+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGTERM.
2016-06-28T20:23:08.802622+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGUSR1.
2016-06-28T20:23:08.802790+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGHUP.
2016-06-28T20:23:08.802942+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Bus STARTING
2016-06-28T20:23:08.803132+00:00 app[web.1]: CherryPy Checker:
2016-06-28T20:23:08.803139+00:00 app[web.1]: The Application mounted at '' has an empty config.
2016-06-28T20:23:08.803140+00:00 app[web.1]:
2016-06-28T20:23:08.803640+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Started monitor thread '_TimeoutMonitor'.
2016-06-28T20:23:08.803919+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Started monitor thread 'Autoreloader'.
2016-06-28T20:23:08.955231+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Serving on http://127.0.0.1:33860
2016-06-28T20:23:08.955533+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Bus STARTED
2016-06-28T20:24:06.045442+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-28T20:24:06.045345+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
好的,这个问题有几个陷阱。到目前为止,最常见的是不使用环境变量 PORT 中指定的端口。第二种是使用 localhost 或 127.0.0.1(或保留默认值)您指定的主机。将主机指定为 0.0.0.0 为我修复了它。
if __name__ == "__main__":
import sys
print( 'HELLO %s' % str(sys.argv[1]))
import os
import os
port = os.environ['PORT']
print(port)
cherrypy.config.update({
'server.socket_host': '0.0.0.0',
'server.socket_port': int(port),
})
cherrypy.quickstart(House())
好的,以前用简单的解决方案回答了类似的问题。不要认为这是一样的。首先是我的代码然后是日志。我正在使用提供的 PORT 环境变量,但我仍然收到此错误。
if __name__ == "__main__":
import sys
print( 'HELLO %s' % str(sys.argv[1]))
#import os
import os
port = os.environ['PORT']
print(port)
cherrypy.config.update({
'server.socket_port': int(port),
})
cherrypy.quickstart(House())
日志来了
2016-06-28T20:23:08.801989+00:00 app[web.1]: HELLO 33860
2016-06-28T20:23:08.802004+00:00 app[web.1]: 33860
2016-06-28T20:23:08.802471+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGTERM.
2016-06-28T20:23:08.802622+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGUSR1.
2016-06-28T20:23:08.802790+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Listening for SIGHUP.
2016-06-28T20:23:08.802942+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Bus STARTING
2016-06-28T20:23:08.803132+00:00 app[web.1]: CherryPy Checker:
2016-06-28T20:23:08.803139+00:00 app[web.1]: The Application mounted at '' has an empty config.
2016-06-28T20:23:08.803140+00:00 app[web.1]:
2016-06-28T20:23:08.803640+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Started monitor thread '_TimeoutMonitor'.
2016-06-28T20:23:08.803919+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Started monitor thread 'Autoreloader'.
2016-06-28T20:23:08.955231+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Serving on http://127.0.0.1:33860
2016-06-28T20:23:08.955533+00:00 app[web.1]: [28/Jun/2016:20:23:08] ENGINE Bus STARTED
2016-06-28T20:24:06.045442+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-28T20:24:06.045345+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
好的,这个问题有几个陷阱。到目前为止,最常见的是不使用环境变量 PORT 中指定的端口。第二种是使用 localhost 或 127.0.0.1(或保留默认值)您指定的主机。将主机指定为 0.0.0.0 为我修复了它。
if __name__ == "__main__":
import sys
print( 'HELLO %s' % str(sys.argv[1]))
import os
import os
port = os.environ['PORT']
print(port)
cherrypy.config.update({
'server.socket_host': '0.0.0.0',
'server.socket_port': int(port),
})
cherrypy.quickstart(House())