Python 古尼康公司;heroku的瓶子设置
我在heroku上玩瓶子游戏,想换一个更“生产”的WSGI服务器gunicorn。以下是我的设置:Python 古尼康公司;heroku的瓶子设置,python,heroku,wsgi,bottle,gunicorn,Python,Heroku,Wsgi,Bottle,Gunicorn,我在heroku上玩瓶子游戏,想换一个更“生产”的WSGI服务器gunicorn。以下是我的设置: import os import bottle from bottle import route, run, template, request, static_file, error class StripPathMiddleware(object): def __init__(self, app): self.app = app def __call__(se
import os
import bottle
from bottle import route, run, template, request, static_file, error
class StripPathMiddleware(object):
def __init__(self, app):
self.app = app
def __call__(self, e, h):
e['PATH_INFO'] = e['PATH_INFO'].rstrip('/')
return self.app(e, h)
# ................................................................. #
@error(404)
def error404(error):
return template('view/404.tpl')
app = bottle.app()
run(app=StripPathMiddleware(app), server='gunicorn', host='0.0.0.0', port=int(os.environ.get("PORT", 5000)), debug=True, workers=3)
这是我的程序文件:
我在SimpleServer.py应用程序中尝试了Procfile,设置了工人数量,也没有设置工人数量
在本地计算机上,它仅在应用程序中我有工人=3且我没有指定工人启动gunicorn:
但foreman start有个问题,不管我使用什么设置,我都会得到:
(bottleServ)caerus@Artem:~/bottleServ$ foreman start
23:31:57 web.1 | started with pid 18192
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Listening at: http://0.0.0.0:5000 (18195)
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Using worker: sync
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [INFO] Booting worker with pid: 18200
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [INFO] Booting worker with pid: 18201
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [INFO] Booting worker with pid: 18202
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [ERROR] Retrying in 1 second.
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [ERROR] Retrying in 1 second.
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [ERROR] Retrying in 1 second.
任何想法都将不胜感激!) 您正在启动gunicorn运行应用程序,然后使用生成另一台服务器(至少在Heroku上)。出现错误的原因是初始服务器使用端口5000,而第二台服务器无法访问该端口。试着运行你的瓶子应用程序(pythonsimpleserver.py),它应该创建服务器本身。此外,当您将“app”传递到run时,http服务器会生成您的应用程序的另一个副本(这会生成另一个gunicorn服务器),所以只需删除该副本即可
run(server='gunicorn', host='0.0.0.0', port=int(os.environ.get("PORT", 5000)), debug=True, workers=X)
python SimpleServer.py
应该就是你所需要的了。谢谢,这很有道理。我丢失了一个WSGI“app”对象。有同样的问题。删除app.run()对我很有效。谢谢
(bottleServ)caerus@Artem:~/bottleServ$ foreman start
23:31:57 web.1 | started with pid 18192
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Listening at: http://0.0.0.0:5000 (18195)
23:31:58 web.1 | 2013-02-02 23:31:58 [18195] [INFO] Using worker: sync
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [INFO] Booting worker with pid: 18200
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [INFO] Booting worker with pid: 18201
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [INFO] Booting worker with pid: 18202
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18202] [ERROR] Retrying in 1 second.
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Bottle v0.11.6 server starting up (using GunicornServer(workers=3))...
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Listening on http://0.0.0.0:5000/
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | Hit Ctrl-C to quit.
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [INFO] Starting gunicorn 0.17.2
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [ERROR] Connection in use: ('0.0.0.0', 5000)
23:31:58 web.1 | 2013-02-02 23:31:58 [18200] [ERROR] Retrying in 1 second.
23:31:58 web.1 | 2013-02-02 23:31:58 [18201] [ERROR] Retrying in 1 second.
run(server='gunicorn', host='0.0.0.0', port=int(os.environ.get("PORT", 5000)), debug=True, workers=X)
python SimpleServer.py