Systemd不会重新启动服务,尽管Restart = always


10

这是我的systemd服务的单位文件:

[Unit]
Description=Tunnel For %i
After=network.target

[Service]
User=autossh
ExecStart=/usr/bin/autossh -M 0 -N -o "ExitOnForwardFailure yes" -o "ConnectTimeout=1" -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -R 40443:installserver:40443 -R 8080:installserver:8080 tunnel@%i
Restart=always

[Install]
WantedBy=multi-user.target

该单元在15天前发生了故障,尽管上面的单元文件中有“ Restart = always”,但systemd并未重新启动它。

这是该服务的状态输出:

salt:/srv # systemctl status autossh@eins-work
autossh@eins-work.service - Tunnel For eins-work
      Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
      Active: failed (Result: start-limit) since Wed, 2016-02-10 14:33:34 CET; 2 weeks and 1 days ago
    Main PID: 17980 (code=exited, status=0/SUCCESS)
      CGroup: name=systemd:/system/autossh@.service/eins-work

Feb 10 14:33:34 salt systemd[1]: Stopping Tunnel For eins-work...
Feb 10 14:33:34 salt systemd[1]: Starting Tunnel For eins-work...
Feb 10 14:33:34 salt systemd[1]: Failed to start Tunnel For eins-work.
Feb 10 14:33:34 salt systemd[1]: Unit autossh@eins-work.service entered failed state

相关:https : //serverfault.com/a/563401/90324

如何配置systemd服务以在出现故障时始终重新启动?


失败后可以手动启动吗?
唐潘

Answers:


4

该服务无法连续启动太多次,因此systemd放弃了尝试。这是什么Result: start-limit意思

请注意,已配置Restart=且达到启动极限的设备不再尝试重启。但是,它们仍然可以在以后手动重启,从那时起,重启逻辑将再次被激活。请注意,这systemctl reset-failed将导致刷新服务的重新启动速率计数器,这在管理员想要手动启动设备且启动限制与此干扰的情况下很有用。

您应该解决导致服务无法启动的问题。

如果您需要调整了多少次,以及如何快速systemd尝试重新启动失败的服务,看到StartLimitInterval=StartLimitBurst=StartLimitAction=选项

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.