2016-06-28 57 views
1

確實類似的問題以簡單的解決方案回答。不要以爲這是一樣的。首先是我的代碼,然後是日誌。我正在使用提供的PORT env變量,但仍然出現此錯誤。

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 

回答

2

OK有在這一個陷阱夫婦的。到目前爲止,最常見的是不使用環境變量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()) 
+0

請隨時單擊旁邊的灰色複選標記以「接受」您的答案;這樣其他人可以一眼就看出你的問題已經解決。 – webKnjaZ

相關問題