无法启动但可以启用并启动服务

无法启动但可以启用并启动服务

我为 strelaysvr 创建了服务:

[Unit]
Description=Syncthing Relay Server
After=network.target

[Service]
ExecStart=/usr/bin/strelaysrv -keys /srv/strelaysrv/keys
User=strelaysrv

[Install]
WantedBy=multi-user.target

并将其放入/srv/strelaysvr/strelaysvr.service,我符号链接到/etc/systemd/系统

然后继续编辑systemctl enable它,systemctl start编辑它,一切正常,直到重新启动:之后,它似乎“消失”:

root@here:~# systemctl start strelaysrv
Failed to start strelaysrv.service: Unit strelaysrv.service not found.
root@here:~# ll /etc/systemd/system/strelaysrv.service 
lrwxrwxrwx 1 root root 34 Apr  2 22:59 /etc/systemd/system/strelaysrv.service -> /srv/strelaysrv/strelaysrv.service
root@here:~# ll /etc/systemd/system/multi-user.target.wants/strelaysrv.service 
lrwxrwxrwx 1 root root 34 Apr  2 23:00 /etc/systemd/system/multi-user.target.wants/strelaysrv.service -> /srv/strelaysrv/strelaysrv.service
root@here:~# ll /srv/strelaysrv/strelaysrv.service
-rw-r--r-- 1 root root 185 Apr  2 22:58 /srv/strelaysrv/strelaysrv.service

但只要调用systemctl enable成功,我就可以重新开始!我究竟做错了什么?我遇到了系统错误吗?

root@here:~# lsb_release -a |& grep escr
Description:    Debian GNU/Linux 9.4 (stretch)
root@here:~# dpkg -s systemd | grep ersion
Version: 232-25+deb9u3

答案1

单元文件(在这种情况下strelaysrv.service需要位于 systemd 启动时已安装的分区中,这在您的示例中不是这种情况,因为在您提到的注释中/srv是一个符号链接,/home其下位于其自己的分区中。

这在 systemd 错误报告中经常出现,最近的一份报告这里

另请参阅(最近更新)systemctl 的手册页其中指出:

当 systemd 启动时,链接单元文件所在的文件系统必须是可访问的(例如,不允许 /home 或 /var 下的任何目录,除非这些目录位于根文件系统上)。

推荐的解决方案是创建strelaysrv.serviceunder的副本/etc/systemd/system而不是符号链接。这应该可以解决问题。

相关内容