服务器作为系统服务切换到gunicorn套接字后,服务器返回502 Bad Gateway

时间:2019-04-28 17:13:16

标签: django nginx gunicorn systemd

我尝试使用它作为systemd服务为Django应用程序和nginx服务器设置gunicorn套接字。但是,运行guncicorn.socket服务nginx服务器的其他用户返回502 Bad Gateway。

重新启动gunicorn.service并检查其状态后,它仍然存在,但是套接字文件在/ run / gunicorn diercotory中,使用后请购买         curl --unix-socket / run / gunicorn / socket http --trace-ascii dump.txt

它返回

    == Info: Rebuilt URL to: http/
    == Info:   Trying /run/gunicorn/socket...
    == Info: Connected to http (/run/gunicorn/socket) port 80 (#0)
    => Send header, 68 bytes (0x44)
    0000: GET / HTTP/1.1
    0010: Host: http
    001c: User-Agent: curl/7.47.0
    0035: Accept: */*
    0042: 
    == Info: Recv failure: Połączenie zerwane przez drugą stronę
    == Info: Closing connection 0
    curl: (56) Recv failure: Połączenie zerwane przez drugą stronę

该套接字文件消失后,下一条消息是

   hesmeron@hesmeron-All-Series:/etc/systemd/system$ curl --unix-     socket   /run/gunicorn/socket http --trace-ascii dump.txt
    == Info: Rebuilt URL to: http/
    == Info:   Trying /run/gunicorn/socket...
    == Info: Immediate connect fail for /run/gunicorn/socket: Nie ma        takiego pliku ani katalogu
    == Info: Closing connection 0
    curl: (7) Couldn't connect to server

这是gunicorn.service追溯

● gunicorn.socket - gunicorn socket
   Loaded: loaded (/etc/systemd/system/gunicorn.socket; enabled; vendor preset: enabled)
   Active: failed (Result: service-start-limit-hit) since nie 2019-04-28 15:30:19 CEST; 1h 58min ago
   Listen: /run/gunicorn/socket (Stream)

kwi 28 15:30:15 hesmeron-All-Series systemd[1]: Closed gunicorn socket.
kwi 28 15:30:15 hesmeron-All-Series systemd[1]: Listening on gunicorn socket.
kwi 28 15:30:19 hesmeron-All-Series systemd[1]: gunicorn.socket: Unit entered failed state.

我阅读了其他类似的问题,只是添加SECRET_KEY或EnvironmentFile无效。

gunicorn.service

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

[Service]
Environment="SECRET_KEY='example'"
PIDFile=/run/gunicorn/pid
User=someuser
Group=someuser
RuntimeDirectory=gunicorn
WorkingDirectory=/home/hesmeron/media_site
ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/pid   \
  --bind unix:/run/gunicorn/socket spartakus.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
EnvironmentFile=/home/hesmeron/envs/spartakus

[Install]
WantedBy=multi-user.target

gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn/socket

[Install]
WantedBy=sockets.target

gunicorn.conf

d /run/gunicorn 0755 someuser somegroup -

如果有任何帮助,我将非常感激

0 个答案:

没有答案