我试图在Ubuntu12.04系统中从管理器运行Gunicorn。Gunicorn运行一个Flask应用程序(使用Flask的嵌入式服务器测试简单的RestWeb服务)。我通过关闭GIT repo安装了Gunicorn,试图避免“apt get install”,因为它在安装时运行Gunicorn服务器。我不想让它运行,它将只由主管运行。
所以在安装之后,如果我尝试:
cd /usr/local/bin
gunicorn my_app:app -c /path/to/gu_config_file
Gunicorn工作。然后我就杀了它。没有扩展名的便笺配置文件,因为扩展名为“.py”的文件对我不起作用。 所以我编辑主管的配置文件如下:
[program:gunicorn]
command=/usr/local/bin/gunicorn my_app:app -c /path/to/.gu_setup
directory=/usr/local/bin/
autostart=true
autorestart=true
redirect_stderr=True
并更新主管的变更:
supervisorctl reread
# gunicorn: changed
supervisorctl update
# gunicorn: stopped
# gunicorn: updated process group
检测文件中的更改并为Gunicorn程序工作。好吧,但我试着开始:
supervisorctl start gunicorn
变得烦人:
gunicorn: ERROR (abnormal termination)
检查主管日志:
2013-03-08 13:07:22,378 INFO spawned: 'gunicorn' with pid 3355
2013-03-08 13:07:22,916 INFO exited: gunicorn (exit status 3; not expected)
2013-03-08 13:07:23,918 INFO spawned: 'gunicorn' with pid 3361
2013-03-08 13:07:24,492 INFO exited: gunicorn (exit status 3; not expected)
2013-03-08 13:07:26,496 INFO spawned: 'gunicorn' with pid 3367
2013-03-08 13:07:27,078 INFO exited: gunicorn (exit status 3; not expected)
2013-03-08 13:07:30,085 INFO spawned: 'gunicorn' with pid 3373
2013-03-08 13:07:30,628 INFO exited: gunicorn (exit status 3; not expected)
2013-03-08 13:07:31,630 INFO gave up: gunicorn entered FATAL state, too many start retries too quickly
我不知道现在该怎么办。。。你能帮助我吗? 太多了!
编辑:抱歉,我忘记说我已经将PYTHONPATH变量导出为:
export PYTHONPATH=/usr/local/bin:/usr/local/lib/project
“我的应用程序”位于/usr/local/bin中。其他模块需要lib路径。 我还编辑了Supervisor配置文件以指示环境变量,例如:
environment=PYTHONPATH=/usr/local/bin:/usr/local/lib/project/
但没用。
编辑2:正如@robertklep在他的评论中所建议的,这是log的输出:
Traceback (most recent call last):
File "/tmp/gunicorn/gunicorn/arbiter.py", line 485, in spawn_worker
worker.init_process()
File "/tmp/gunicorn/gunicorn/workers/base.py", line 100, in init_process
self.wsgi = self.app.wsgi()
File "/tmp/gunicorn/gunicorn/app/base.py", line 103, in wsgi
self.callable = self.load()
File "/tmp/gunicorn/gunicorn/app/wsgiapp.py", line 25, in load
return util.import_app(self.app_uri)
File "/tmp/gunicorn/gunicorn/util.py", line 369, in import_app
__import__(module)
File "/usr/local/bin/my_app.py", line 4, in <module>
import const
ImportError: No module named const
2013-03-08 13:29:35 [3670] [INFO] Worker exiting (pid: 3670)
2013-03-08 13:29:36 [3665] [INFO] Shutting down: Master
2013-03-08 13:29:36 [3665] [INFO] Reason: Worker failed to boot.
“const”模块位于/usr/local/lib/project中。。。
这不是必要的通行证--Python。如果你使用virtualenv,你把add放在gunicorn的位置。示例:
当Flask代码为时,目录为,例如:
记住用户是根用户!
我看不到您在主管配置文件中设置环境:
如果不起作用,请尝试在调试模式下启动gunicorn:
或者直接穿过这条路到gunicorn:
编辑:gunicorn的
--pythonpath
已损坏,您只能传递一个目录:相关问题 更多 >
编程相关推荐