gpt4 book ai didi

django - 设置 gunicorn 与 systemd 一起运行

转载 作者:行者123 更新时间:2023-12-04 00:05:56 24 4
gpt4 key购买 nike

正在尝试设置 gunicornsystemd 一起运行.控制文件是 /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.

由于 ExecStart,错误显示在 gunicorn 服务的第 9 行开始
[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

最佳答案

它告诉你它不想要 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 服务配置文件。

    希望这可以帮助!

    关于django - 设置 gunicorn 与 systemd 一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44818451/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com