我正在设置一个没有 virtualenv 的 django 站点,我正在关注 digital ocean's guide设置一直进展顺利,直到我必须设置gunicorn服务实例,该实例有一个字段ExecStart
,我在尝试测试时也必须将其删除。
当我尝试启动 Gunicorn 时,出现以下错误
root@samuel-pc:~/revamp# systemctl start gunicorn
Failed to start gunicorn.service: Unit gunicorn.service is not loaded properly: Invalid argument.
See system logs and 'systemctl status gunicorn.service' for details.
root@samuel-pc:~/revamp#
我的gunicorn服务代码如下:
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/root/revamp
#ExecStart=gunicorn --access-logfile - --workers 3 --bind unix:/root/revamp/rev$
[Install]
WantedBy=multi-user.target
我设置网站的方式是通过 root 登录,然后将文件夹直接复制到 root 中。 django 应用程序称为 revamp,如果您从文件夹内运行 pwd,您将得到结果 /root/revamp
更新
我已将 execstart 编辑为
ExecStart=gunicorn --access-logfile - --workers 3 --bind unix:/root/revamp/revamp.sock revamp.wsgi:application
现在当我运行systemctl status Gunicorn.service时
我明白
● gunicorn.service - gunicorn daemon
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
Jun 28 21:48:16 samuel-pc systemd[1]: [/etc/systemd/system/gunicorn.service:9] Executable path is not absolute, ignoring: gunicorn --access-logfile - --workers 3 --bind unix:/root/revamp/revamp
Jun 28 21:48:16 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 28 21:53:29 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 05:05:06 samuel-pc systemd[1]: [/etc/systemd/system/gunicorn.service:9] Executable path is not absolute, ignoring: gunicorn --access-logfile - --workers 3 --bind unix:/root/revamp/revamp
Jun 29 05:05:06 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 05:05:24 samuel-pc systemd[1]: [/etc/systemd/system/gunicorn.service:9] Executable path is not absolute, ignoring: gunicorn --access-logfile - --workers 3 --bind unix:/root/revamp/revamp
Jun 29 05:05:24 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
最佳答案
您可以通过输入
找到您的gunicorn安装路径which gunicorn
对我来说(常规安装)返回了
/usr/local/bin/gunicorn
所以最后你会得到这样的东西:
ExecStart=/usr/local/bin/gunicorn --access-logfile - --workers 3 [...]
关于django - 在没有 virtualenv 的情况下配置 Gunicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44813210/