2
我正在關注this document以爲我的gunicorn服務器設置Systemd套接字和服務。Systemd +非根Gunicorn服務=已停用的子進程
- Systemd開始gunicorn爲
www-data
- gunicorn叉本身(默認行爲)
- 服務器開始與
subprocess.Popen()
- 子進程完成一個子沒有錯誤,但父母一直從
p.poll()
獲得無而不是退出代碼 - 子過程結束失效
這裏的進程層次:
$ ps eauxf
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
...
www-data 14170 0.0 0.2 65772 20452 ? Ss 10:57 0:00 /usr/bin/python /usr/bin/gunicorn digits.webapp:app --pid /run/digits/pid --config /usr/lib/python2.7/dist-packages/digits/gunicorn_config.py
www-data 14176 0.8 3.4 39592776 283124 ? Sl 10:57 0:05 \_ /usr/bin/python /usr/bin/gunicorn digits.webapp:app --pid /run/digits/pid --config /usr/lib/python2.7/dist-packages/digits/gunicorn_config.py
www-data 14346 5.0 0.0 0 0 ? Z 11:07 0:01 \_ [python] <defunct>
這裏的踢球:當我運行該服務爲root
,而不是www-data
,一切正常。子進程結束,父進程立即獲取子進程的返回碼。
/lib/systemd/system/digits.service
[Unit]
Description=DIGITS daemon
Requires=digits.socket
After=local-fs.target network.target
[Service]
PIDFile=/run/digits/pid
User=www-data
Group=www-data
Environment="DIGITS_JOBS_DIR=/var/lib/digits/jobs"
Environment="DIGITS_LOGFILE_FILENAME=/var/log/digits/digits.log"
ExecStart=/usr/bin/gunicorn digits.webapp:app \
--pid /run/digits/pid \
--config /usr/lib/python2.7/dist-packages/digits/gunicorn_config.py
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
/lib/systemd/system/digits.socket
[Unit]
Description=DIGITS socket
[Socket]
ListenStream=/run/digits/socket
ListenStream=0.0.0.0:34448
[Install]
WantedBy=sockets.target
/usr/lib/tmpfiles.d/digits.conf
d /run/digits 0755 www-data www-data -
我放棄了,現在停止使用gunicorn。我需要在某一天解決這個問題,所以如果有人有任何想法,請讓我知道! –
我今天整天都有同樣的問題。我遵循這個文件(類似於你指出的那封):http://docs.gunicorn.org/en/stable/deploy.html(._。)感嘆。 –