systemd:从systemctl挂起恢复

时间:2017-07-28 15:04:15

标签: service systemd systemctl

我有一个自定义的systemd“.service”文件,如下所示:

[Unit]
Description=MyStuff
After=syslog.target
After=network.target
After=local-fs.target
After=remote-fs.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/MyStuff/start
ExecReload=/bin/kill $MAINPID && /usr/bin/cat /var/run/MyStuff.pid | /usr/bin/xargs --no-run-if-empty /bin/kill
ExecStop=/bin/kill $MAINPID && /usr/bin/cat /var/run/MyStuff.pid | /usr/bin/xargs --no-run-if-empty /bin/kill
ExecStartPost=/usr/local/MyStuff/after_start.sh
PIDFile=/var/run/MyStuff.pid
#RemainAfterExit=yes
TimeoutSec=300
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

几分钟前它运作良好。 systemctl stop MyStuff以这种方式挂起:

[root@Live-1 ffmpeg]# systemctl status WowzaStreamingEngine
● MyStuff.service - MyStuff
   Loaded: loaded (/usr/lib/systemd/system/MyStuff.service; enabled; vendor preset: disabled)
   Active: deactivating (final-sigkill) (Result: timeout) since vie 2017-07-28 11:12:23 -03; 23min ago
Main PID: 25149
CGroup: /system.slice/MyStuff.service

jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "/usr/bin/cat"
jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "/var/run/MyStuff.pid"
jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "|"
jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "/usr/bin/xargs"
jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "--no-run-if-empty"
jul 28 11:12:23 Live-1 kill[10382]: kill: cannot find process "/bin/kill"
jul 28 11:12:23 Live-1 systemd[1]: MyStuff.service: control process exited, code=exited status=1
jul 28 11:17:24 Live-1 systemd[1]: MyStuff.service stop-sigterm timed out. Killing.
jul 28 11:22:24 Live-1 systemd[1]: MyStuff.service still around after SIGKILL. Ignoring.
jul 28 11:31:22 Live-1 systemd[1]: MyStuff.service stop-final-sigterm timed out. Killing.

我知道那里有错误报道。那不是问题;我不是在问这些错误。问题是: systemd / systemctl在该状态下挂起,我无法执行启动/停止/重启动作,因为它们都会一直等待

我需要知道的是绕过那个州。这次我只是重新启动了服务器,因为它是开发环境。但我不能只是这样处理生产。

所以:当systemd / systemctl以这种方式挂起时,为了在不重新启动服务器的情况下从此状态恢复服务,我该怎么办?

提前致谢。

0 个答案:

没有答案