赞
踩
我有一个老派守护进程,我想用systemd控制.当其配置文件发生更改时,需要将其终止并重新启动.换句话说,在编辑配置文件之后,systemctl重新加载MYSERVICE应该终止进程并重新启动它.
尝试1:尝试默认值.这告诉systemd如何启动守护进程,而不是如何重新加载它.
[Service]
ExecStart=/usr/bin/MYSERVICE
Type=simple
因此,启动和重新启动工作,但重新加载会出现此错误:
# systemctl reload MYSERVICE
Failed to reload MYSERVICE.service: Job type reload is not applicable for unit MYSERVICE.service.
尝试2:告诉它如何杀死进程.这会终止进程,但systemd不会为我重新启动它.
[Service]
ExecStart=/usr/bin/MYSERVICE
Type=simple
ExecReload=/bin/kill -HUP $MAINPID
…其次是…
# systemctl daemon-reload
# systemctl reload MYSERVICE
…杀死进程但不会自动重启.
尝试3:使用ExecReload重启过程.这失败的原因有以下几点:
ExecReload=/bin/kill -HUP $MAINPID ; /usr/bin/MYSERVICE
…我得到的错误信息……:
# systemctl daemon-reload
# systemctl reload MYSERVICE
Job for MYSERVICE.service failed because the control process exited with error code. See "systemctl status MYSERVICE.service" and "journalctl -xe" for details.
我希望有一个ReloadType = kill_and_restart或其他东西,但没有这样的运气.
如何告诉systemd在重载时杀死并重启守护进程?
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。