【问题标题】:gunicorn [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoringgunicorn [/etc/systemd/system/gunicorn.socket:6] 未知部分“服务”。忽略
【发布时间】:2019-05-17 08:19:47
【问题描述】:

我正在 digitalocean 上设置 django,虽然 gunicorn 不起作用,但他们有一个设置规则,这次可以正常工作。

第一步是使用这个命令sudo nano /etc/systemd/system/gunicorn.service设置gunicorn服务

内容

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/webapp/prestige
ExecStart=/home/sammy/webapp/envs/prestige/bin/gunicorn \
        --access-logfile - \
        --workers 3 \
        --bind unix:/run/gunicorn.sock \
        prestige.wsgi:application

[Install]
WantedBy=multi-user.target

和套接字文件sudo nano /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

注意这个目录

/home/sammy/webapp/prestige

是 django 的主文件夹目录,manage.py 所以基本上如果我 cd 进入它,我可以运行 python manage.py runserver 并且它可以工作。

这是虚拟环境的文件夹

/home/sammy/webapp/envs/prestige

现在当我运行 start gunicorn 命令时,我得到了这个

(prestige) sammy@prestige:~/webapp$ sudo systemctl start gunicorn.socket
Failed to start gunicorn.socket: Unit gunicorn.socket is not loaded properly: Invalid argument.
See system logs and 'systemctl status gunicorn.socket' for details.

如果你检查状态

(prestige) sammy@prestige:~/webapp$ sudo systemctl status gunicorn.socket
● gunicorn.socket - gunicorn daemon
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
May 17 07:25:18 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:25:18 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:33:32 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:33:32 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:34:09 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:34:09 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:53:41 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:53:41 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.
May 17 07:56:59 prestige systemd[1]: [/etc/systemd/system/gunicorn.socket:6] Unknown section 'Service'. Ignoring.
May 17 07:56:59 prestige systemd[1]: gunicorn.socket: Unit lacks Listen setting. Refusing.

不知道发生了什么。

【问题讨论】:

  • 你需要显示 gunicorn.socket 文件。
  • @DanielRoseman 我已经添加了

标签: django gunicorn


【解决方案1】:

发现如果您将错误的代码用于服务或用于 gunicorn 的套接字,它就会出错。刚刚删除了droplet重新启动后,一切顺利。

【讨论】:

    猜你喜欢
    • 2020-05-04
    • 2022-11-01
    • 2019-08-24
    • 1970-01-01
    • 2020-09-27
    • 1970-01-01
    • 2018-09-11
    • 1970-01-01
    • 2021-07-20
    相关资源
    最近更新 更多