【问题标题】:setup gunicorn to run with systemd设置 gunicorn 以使用 systemd 运行
【发布时间】:2017-12-02 18:15:08
【问题描述】:

尝试设置 gunicorn 与 systemd 一起运行。控制文件为/etc/systemd/system/gunicorn.service,测试输出为

root@samuel-pc:~# 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:~# systemctl status gunicorn.service
● gunicorn.service - gunicorn daemon
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Jun 29 05:13:17 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:13:17 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 05:13:29 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:13:29 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 05:15:45 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:15:45 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 07:01:10 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 07:01:10 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Jun 29 07:01:55 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 07:01:55 samuel-pc systemd[1]: gunicorn.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

这表明错误从 gunicorn 服务的第 9 行开始,因为 ExecStart

[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/revamp.sock revamp.wsgi:application


[Install]
WantedBy=multi-user.target

【问题讨论】:

    标签: django gunicorn digital-ocean


    【解决方案1】:

    它告诉您它不需要gunicorn 可执行文件的相对路径:
    Executable path is not absolute, ignoring。

    您需要将其更改为您的gunicorn 可执行文件的绝对路径,或者:

    • 系统可执行文件:ExecStart=/usr/local/bin/gunicorn
    • 您的虚拟环境的可执行文件:ExecStart=/path/to/venv/bin/gunicorn

    您可以查看以下要点:Using Systemd to Make Sure Gunicorn Starts on Boot,以获得最小的 gunicorn systemd 服务配置文件。

    希望这会有所帮助!

    【讨论】:

    • 谢谢,我相信这解决了这个问题,现在我收到了excess arguments 错误
    • 可以发日志吗?
    猜你喜欢
    • 2018-02-09
    • 2016-09-12
    • 2016-07-24
    • 2018-12-09
    • 2021-01-04
    • 2014-01-12
    • 1970-01-01
    • 2022-11-10
    • 2017-01-19
    相关资源
    最近更新 更多