首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenResty服务挂起,但ExecStart工作正常

OpenResty服务挂起,但ExecStart工作正常
EN

Ask Ubuntu用户
提问于 2022-06-23 19:32:01
回答 1查看 249关注 0票数 0

我正在使用GCP上Ubuntu上的标准包安装的默认openresty。

0 5.15.0-1010-gcp #15-Ubuntu 10 : 11:30:24 UTC 2022 x86_64 GNU/Linux

OpenResty的服务文件如下所示:

代码语言:javascript
复制
# 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,以防由于某些原因,它没有正确地分叉,但这也没有帮助。

EN

回答 1

Ask Ubuntu用户

发布于 2022-06-23 19:58:32

弄明白了。

在我的nginx.conf文件中,我将PID位置设置为/var/run/nginx.pid。

在openresty.services文件中,它有一个硬编码的PID位置。通过删除我的nginx.conf文件中的PID位置,它可以正常工作。

票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1415477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档