在Django中运行Gunicorn时出错

时间:2018-07-15 07:54:33

标签: django python-3.6 gunicorn

我在运行Gunicorn时出错。

Started gunicorn daemon.
Starting gunicorn daemon...
[2018-07-15 07:39:16 +0000] [11359] [INFO] Starting gunicorn 19.9.0
[2018-07-15 07:39:16 +0000] [11359] [INFO] Listening at: http://0.0.0.0:4000 (11359)
[2018-07-15 07:39:16 +0000] [11359] [INFO] Using worker: sync
[2018-07-15 07:39:16 +0000] [11362] [INFO] Booting worker with pid: 11362
[2018-07-15 07:39:16 +0000] [11362] [ERROR] Exception in worker process
Traceback (most recent call last):File "/home/ec2-user/bankserver/env/lib   /python3.6/site-packages/gunicorn/arbiter.py", lineworker.init_process()
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn /workers/base.py",self.load_wsgi()
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn/workers/base.py",self.wsgi = self.app.wsgi()
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn/app/base.py", linself.callable = self.load()
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",return self.load_wsgiapp()
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py",return util.import_app(self.app_uri)
File "/home/ec2-user/bankserver/env/lib/python3.6/site-packages/gunicorn/util.py", line 35
__import__(module)
ModuleNotFoundError: No module named 'aggregator'
[2018-07-15 07:39:16 +0000] [11362] [INFO] Worker exiting (pid: 11362)
[2018-07-15 07:39:16 +0000] [11359] [INFO] Shutting down: Master
[2018-07-15 07:39:16 +0000] [11359] [INFO] Reason: Worker failed to boot.
gunicorn.service: main process exited, code=exited, status=3/NOTIMPLEMENTED
Unit gunicorn.service entered failed state.
gunicorn.service failed.

安装路径:     我已经在/ home / ec2-user / bserver / env / bin / *中安装了虚拟环境     我在/ home / ec2-user / sigma_app / django_app_04-07-2018 / aggregator(这里的聚合器是项目名称)中有django应用程序

gunicorn.service包含:

[Unit]
Description=gunicorn daemon
After=network.target

[Service]
User=ec2-user
Group=ec2-user
WorkingDirectory=/home/ec2-user/sigma_app/django_app_04-07-2018/aggregator
ExecStart=/home/ec2-user/bserver/env/bin/python3.6 /home/ec2-user/bserver/env/bin/gunicorn --workers 3 --bind :4000 aggregator.wsgi:application

1 个答案:

答案 0 :(得分:0)

我自己找到了解决方法。

我已从中替换了工作目录

WorkingDirectory = / home / ec2-user / sigma_app / django_app_04-07-2018 / aggregator to

WorkingDirectory = / home / ec2-user / sigma_app / django_app_04-07-2018

对我有用