我的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-reloadsystemctl start app时失败,错误如下:
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 reload app.service的输出为:
● 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 status app时,没有任何结果;它是空白的?
我试过做一个systemctl show app.service -p TimeoutSec,但仍然没有骰子。
当然,当我将值更改为其他任何值(如systemctl reboot)时,它工作得非常好。但我真的需要这个应用程序来处理无穷大。
我哪里做错了?

最佳答案

TimeoutSec=0修复了问题。
显然,如果使用的systemd版本早于229,则需要使用0而不是无穷来禁用超时。

08-04 06:21