我正在尝试使用 gunicorn、nginx 在本地机器上设置一个 django 项目。
我确实/etc/systemd/system/gunicorn.service
按照本教程设置了 gunicornhttps://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04
下面共享/etc/systemd/system/gunicorn.service
文件配置。
Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target
[Service]
User=bm
Group=www-data
WorkingDirectory=/home/bm/www/html/erp
ExecStart=/home/bm/www/html/erp/env/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
erp.erp.wsgi:application
[Install]
WantedBy=multi-user.target
当我尝试运行时sudo systemctl status gunicorn
。它给出了错误响应gunicorn.service: Failed at step EXEC spawning /home/bm/www/html/erp/env/bin/gunicorn: No such file or directory
。按照教程,我没有得到gunicorn
在文件夹中创建文件的任何步骤erp/env/bin
。我需要在 bin 文件夹中创建一个 gunicorn 文件吗?或者需要任何其他配置来解决这个问题?
下面我分享了我的完整错误消息。如果有人有任何想法,请帮忙吗?
bm@Lenovo:~/www/html/erp/erp$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2019-04-14 21:12:06 IST; 52min ago
Main PID: 5932 (code=exited, status=203/EXEC)
Apr 14 21:12:06 Lenovo systemd[1]: Started gunicorn daemon.
Apr 14 21:12:06 Lenovo systemd[5932]: gunicorn.service: Failed to execute command: No such file or directory
Apr 14 21:12:06 Lenovo systemd[5932]: gunicorn.service: Failed at step EXEC spawning /home/bm/www/html/erp/env/bin/gunicorn: No such file or directory
Apr 14 21:12:06 Lenovo systemd[1]: gunicorn.service: Main process exited, code=exited, status=203/EXEC
Apr 14 21:12:06 Lenovo systemd[1]: gunicorn.service: Failed with result 'exit-code'.
Apr 14 21:12:30 Lenovo systemd[1]: /etc/systemd/system/gunicorn.service:10: Executable path is not absolute: gunicorn --access-logfile - --workers 3 --bind uni
Apr 14 21:15:08 Lenovo systemd[1]: /etc/systemd/system/gunicorn.service:10: Executable path is not absolute: gunicorn --access-logfile - --workers 3 --bind uni
lines 1-12/12 (END)
答案1
我解决了我的问题。实际上 gunicorn 没有在我的虚拟环境中正确安装,因此没有创建 gunicorn 文件。