moo*_*ing 27 linux nginx systemd
调用有区别吗
systemctl reload nginx
Run Code Online (Sandbox Code Playgroud)
并打电话
nginx -s reload
Run Code Online (Sandbox Code Playgroud)
?
我知道,除了 systemd,还有其他初始化系统,如 SysV 和 Upstart。所以也许这个问题也适用于他们。
是通过 init 系统发出这个命令还是我可以只调用 nginx 本身?
提前致谢
Tim*_*ier 29
您可以systemd reload nginx
通过查看单元文件(位于我的系统上)部分中的ExecReload=
选项来了解将执行的操作:[Service]
nginx.service
/usr/lib/systemd/system/nginx.service
$ systemctl cat nginx | grep ExecReload=
Run Code Online (Sandbox Code Playgroud)
或者通过运行:
$ systemctl show nginx.service --property=ExecReload
Run Code Online (Sandbox Code Playgroud)
在我的系统上,我得到:
ExecReload=/usr/bin/kill -HUP $MAINPID
Run Code Online (Sandbox Code Playgroud)
来自nginx(8)
:
-s signal Send a signal to the master process. The argument signal
can be one of: stop, quit, reopen, reload. The following
table shows the corresponding system signals:
stop SIGTERM
quit SIGQUIT
reopen SIGUSR1
reload SIGHUP
Run Code Online (Sandbox Code Playgroud)
因此systemctl reload nginx
和nginx -s reload
会,差不多,做同样的事情。
区别在于:
systemctl reload nginx
将在干净的环境(而不是当前用户环境)中执行命令;systemctl reload
适用于任何允许它的服务(在单元文件中配置了它)。无需记住特定于服务的命令。如果您有多个服务实例,这会更有趣。使用service
或init.d
脚本是做同样事情的遗留/弃用方式。尽管它们可能有效,但在基于 systemd 的系统上不再支持或推荐它们。
小智 6
目前 Centos 7 和 RHEL 7 有所不同。使用 systemctl reload nginx 不会验证您的配置。
查看以下错误:https : //bugzilla.redhat.com/show_bug.cgi?id=1565377
因此,我建议使用 nginx -s reload 或更新您的 nginx 单元文件以使用以下 reload 命令:
ExecReload=/usr/sbin/nginx -s reload
Run Code Online (Sandbox Code Playgroud)
https://bugzilla.redhat.com/attachment.cgi?id=1419614&action=diff
归档时间: |
|
查看次数: |
33063 次 |
最近记录: |