【发布时间】:2018-02-04 09:12:38
【问题描述】:
我尝试使用 ngnix-gunicorn 部署 django 应用程序,如下所示: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04 我在没有 virtualenv 的情况下做到了。这是“gunicorn.service”文件。 当我尝试创建一个 systemd 时,我遇到了一个错误。
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
Environment=SECRET_KEY='*uj$'
User=root
Group=www-data
WorkingDirectory=/root/myproject
ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/myproject/myproject.sock myproject.wsgi:application
[Install]
WantedBy=multi-user.target
这里是创建 systemd 时的错误。
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2017-08-26 14:05:19 UTC; 6s ago
Process: 24747 ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 --bind unix:/root/test1/test1.sock test1.wsgi:applica
Main PID: 24747 (code=exited, status=200/CHDIR)
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: Started gunicorn daemon.
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Main process exited, code=exited, status=200/CHDIR
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Unit entered failed state.
Aug 26 14:05:19 ip-172-31-1-229 systemd[1]: gunicorn.service: Failed with result 'exit-code'.
【问题讨论】:
-
您似乎没有指定 gunicorn 应该启动的 WSGI (django) 应用程序。 gunicorn 必须以
gunicorn [OPTIONS] APP_MODULE开头,您似乎缺少APP_MODULE部分。请参阅文档:docs.gunicorn.org/en/stable/run.html -
你能把gunicorn原木放在这里吗?我可以看到它试图运行 gunicorn 但退出。
标签: python linux django gunicorn systemd