代码之家  ›  专栏  ›  技术社区  ›  Sam B.

gunicorn[/etc/systemd/system/gunicorn。socket:6]未知的“服务”部分。忽略

  •  0
  • Sam B.  · 技术社区  · 6 年前

    我正在digitalocean上设置django,他们有一个设置规则,这次可以使用,尽管gunicorn不起作用。

    sudo nano /etc/systemd/system/gunicorn.service

    以及内容

    [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 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.
    

    0 回复  |  直到 6 年前
        1
  •  1
  •   Sam B.    6 年前