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

Changing systemd.service TimeoutSec value to “infinity” has no effect

我的 app.service 文件的 [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 等任何其他值时,它就可以正常工作。但是我真的很需要这个应用占用无穷大

我哪里错了?

TimeoutSec=0 修复了问题。

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