将systemd.service TimeoutSec值更改为“infinity”无效

时间:2017-03-21 07:46:56

标签: linux service centos systemd systemctl

我的app.service文件的[服务]部分如下: -

[Service]
Type=forking
Restart=no
IgnoreSIGPIPE=no
GuessMainPID=no
ExecStart=/opt/app/appl_init.d start
ExecStop=/opt/app/appl_init.d stop
TimeoutSec=infinity

之后我安装了应用程序,并将文件正确复制到/usr/lib/systemd/system/app.service

我已经运行systemctl daemon-reload,但似乎对启动时间没有影响!当我运行systemctl start appsystemctl reload app.service并出现以下错误时,它会失败: -

Job for app.service failed because a fatal signal was delivered to the control process. See "systemctl status app.service" and "journalctl -xe" for details

systemctl status app的输出是: -

● app.service - ApplicationTest
   Loaded: loaded (/opt/app/appl_init.d; enabled; vendor preset: disabled)
   Active: failed (Result: signal) since Tue 2017-03-21 01:55:22 EDT; 1min 4s ago
     Docs: man:app(8)
  Process: 4126 ExecStart=/opt/app/appl_init.d start (code=killed, signal=KILL)

Mar 21 01:55:22 centosvm systemd[1]: Starting ApplicationTest...
Mar 21 01:55:22 centosvm systemd[1]: app.service start operation timed out. Terminating.
Mar 21 01:55:22 centosvm systemd[1]: app.service stop-final-sigterm timed out. Killing.
Mar 21 01:55:22 centosvm systemd[1]: app.service: control process exited, code=killed status=9
Mar 21 01:55:22 centosvm systemd[1]: Failed to start ApplicationTest.
Mar 21 01:55:22 centosvm systemd[1]: Unit app.service entered failed state.
Mar 21 01:55:22 centosvm systemd[1]: app.service failed.

我注意到的另一个奇怪的事情是当我跑systemctl show app.service -p TimeoutSec时,我得不到任何结果;它是空白的吗?

我尝试过systemctl reboot,但仍然没有骰子。

当然,当我将值更改为TimeoutSec=5min之类的其他内容时,它的工作原理非常好。但我真的需要这个应用程序来占用无穷大。

我哪里错了?

1 个答案:

答案 0 :(得分:3)

TimeoutSec=0解决了这个问题。

显然,如果您使用的是早于229的systemd版本,则需要使用0而不是无穷大来禁用超时。