我正在使用GCP上Ubuntu上的标准包安装的默认openresty。
0 5.15.0-1010-gcp #15-Ubuntu 10 : 11:30:24 UTC 2022 x86_64 GNU/Linux
OpenResty的服务文件如下所示:
# Stop dance for OpenResty
# =========================
#
# ExecStop sends SIGSTOP (graceful stop) to OpenResty's nginx process.
# If, after 5s (--retry QUIT/5) nginx is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if nginx is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
#
# nginx signals reference doc:
# http://nginx.org/en/docs/control.html
#
[Unit]
Description=The OpenResty Application Platform
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/local/openresty/nginx/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /usr/local/openresty/nginx/logs/nginx.pid
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target当我从命令行运行ExecStart命令时,它工作得很好。但是当我做service openresty start时,它会挂起,直到超时。
我不知道还会有什么问题?我还尝试将Type设置为simple,以防由于某些原因,它没有正确地分叉,但这也没有帮助。
发布于 2022-06-23 19:58:32
弄明白了。
在我的nginx.conf文件中,我将PID位置设置为/var/run/nginx.pid。
在openresty.services文件中,它有一个硬编码的PID位置。通过删除我的nginx.conf文件中的PID位置,它可以正常工作。
https://askubuntu.com/questions/1415477
复制相似问题