如果状态中有文本,请重新启动 systemd?

如果状态中有文本,请重新启动 systemd?

如何重新启动由特定状态文本触发的 systemd 服务[0],例如403

我对[1​​]的理解Restart=on-failure意味着它不能用于我的特定目的

root@raspberrypi:~# systemctl status raspotify

lines 1--1...skipping...
● raspotify.service - Raspotify
   Loaded: loaded (/lib/systemd/system/raspotify.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-12-11 14:35:19 CET; 18h ago
  Process: 2531 ExecStartPre=/bin/mkdir -m 0755 -p /var/cache/raspotify (code=exited, status=0/SUCCESS)
  Process: 2532 ExecStartPre=/bin/chown raspotify:raspotify /var/cache/raspotify (code=exited, status=0/SUCCESS)
 Main PID: 2533 (librespot)
    Tasks: 2 (limit: 1635)
   CGroup: /system.slice/raspotify.service
           └─2533 /usr/bin/librespot --name raspotify (raspberrypi) --backend alsa --bitrate 160 --disable-audio-cache --enable-volume-normalisation --linear-volume --initial-volume=100 --username foo --passwo

Dec 11 14:35:19 raspberrypi systemd[1]: Starting Raspotify...
Dec 11 14:35:19 raspberrypi systemd[1]: Started Raspotify.
Dec 11 14:35:19 raspberrypi librespot[2533]: [2020-12-11T13:35:19Z INFO  librespot] librespot (raspotify v0.14.0) 6aac8a6 (2020-07-24). Built on 2020-07-26. Build ID: wPNyqn0m
Dec 11 14:35:29 raspberrypi librespot[2533]: [2020-12-11T13:35:29Z WARN  librespot_core::apresolve] Failed to resolve Access Point: HTTP error
Dec 11 14:35:29 raspberrypi librespot[2533]: [2020-12-11T13:35:29Z WARN  librespot_core::apresolve] Using fallback "ap.spotify.com:443"
Dec 11 14:35:29 raspberrypi librespot[2533]: [2020-12-11T13:35:29Z INFO  librespot_core::session] Connecting to AP "ap.spotify.com:443"
Dec 11 14:35:39 raspberrypi librespot[2533]: [2020-12-11T13:35:39Z ERROR librespot] Could not connect to server: failed to lookup address information: Temporary failure in name resolution

现在我手动

root@raspberrypi:~# systemctl restart raspotify

一切都恢复正常了

[0]https://github.com/dtcooper/raspotify

[1]https://www.freedesktop.org/software/systemd/man/systemd.service.html#Restart=

相关内容