尽管 restart=always,但 Systemd 服务未因错误而重新启动

尽管 restart=always,但 Systemd 服务未因错误而重新启动

注意到错误后使用journalctl -u raspotify --since=yesterday | grep ERROR

Dec 26 22:50:11 raspberrypi librespot[3024]: [2020-12-26T21:50:11Z ERROR librespot] Could not connect to server: failed to lookup address information: Temporary failure in name resolution

我使用手动重新启动systemctl restart raspotify

我需要在服务中更改什么才能在出现错误时自动重新启动它

cat /lib/systemd/system/raspotify.service:

[Unit]
Description=Raspotify
After=network.target

[Service]
User=raspotify
Group=raspotify
Restart=always
RestartSec=10
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -m 0755 -p /var/cache/raspotify ; /bin/chown raspotify:raspotify /var/cache/raspotify
Environment="DEVICE_NAME=raspotify (%H)"
Environment="BITRATE=160"
Environment="CACHE_ARGS=--disable-audio-cache"
Environment="VOLUME_ARGS=--enable-volume-normalisation --linear-volume --initial-volume=100"
Environment="BACKEND_ARGS=--backend alsa"
EnvironmentFile=-/etc/default/raspotify
ExecStart=/usr/bin/librespot --name ${DEVICE_NAME} $BACKEND_ARGS --bitrate ${BITRATE} $CACHE_ARGS $VOLUME_ARGS $OPTIONS

[Install]
WantedBy=multi-user.target

ACTION=="add", SUBSYSTEM=="net", KERNEL=="wl*", RUN+="/usr/bin/iw dev $name set power_save off"

相关内容