我正在尝试设置我的gunicorn。以下是我的 systemmd 配置文件的配置文件:
# Unit section is used to specify metadata and dependencies
[Unit]
Description=DEMO
# only start once the network target has been reached
After=network.target
# Service section specify the user and group that we want the process to run under
[Service]
# www-data group assigned to facilitate easy communication with nginx
Group=www-data
# path to working directory
WorkingDirectory=/srv/demo/git
# path to virtual environment
Environment="PATH=/srv/demo/git/venv/bin"
ExecStart=/srv/demo/git/venv/bin/gunicorn --workers=5 --bind unix:git.sock --log-level=debug wsgi:app --timeout 3600
#--workers=5 --threads=2 --worker-class=gthread
[Install]
WantedBy=multi-user.target
~
~
~
我的虚拟环境文件夹确实包含gunicorn:
但是我仍然无法运行这个,systemmd 文件说它无法找到gunicorn。没有这样的文件或目录:
我已经从虚拟环境外部卸载了gunicorn。但是当我执行 which Gunicorn 时,它显示了 /usr/bin/gunicorn 的路径。当我放置此路径时,它不会抛出相同的错误,而只是说找不到 apt_pkg 和 Gunicorn 模块,但不是目录错误。这是路径问题吗?如果是这样我该如何解决?
我希望以下步骤将有助于解决这个问题....
第1步:cd ~/myprojectdir
第2步:源myprojectenv/bin/activate
第3步:哪个gunicorn
第 4 步:将其粘贴到“ExecStart”值交换“/etc/systemd/system/gunicorn.service”的路径部分,其中 guicorn '..../path"
第5步:sudo systemctl daemon-reload
第6步:sudo systemctl重新启动gunicorn
第7步:sudo systemctl status Gunicorn
有几个问题可能会引发此问题,但如果您已经完美解决了所有问题,那么您可以尝试这些快速修复,
pip install gunicorn
)gunicorn -w 4 -b 0.0.0.0:8000 your_project_name.wsgi:application
(sudo systemctl守护进程重新加载
sudo systemctl restart gunicorn)