systemd显然没有找到.service文件

时间:2015-12-28 22:19:24

标签: systemd

我为我们的foo服务组装了一个foo.service文件,该服务作为守护进程运行。当我运行systemctl start foo(和stop)但该服务运行正常 systemtcl enable foo会产生Failed to issue method call: Invalid argument。单元文件放在/etc/systemd/system/foo.service中,并具有权限0755.将systemd设置为debug并运行enable赋予

Looking for unit files in (highest priority first):`
    /etc/systemd/system
    /run/systemd/system
    /usr/local/lib/systemd/system
    /usr/lib/systemd/system
Looking for SysV init scripts in:
    /etc/rc.d/init.d
Looking for SysV rcN.d links in:
    /etc/rd.c
Failed to issue method call: Invalid argument

谷歌搜索似乎就像systemctl一样找不到.service文件。有什么方法可以验证吗?如果是这样,我该如何解决?关于可能出错的其他任何想法?我可以启用更多调试吗?给出的调试信息并没有真正帮助我缩小问题范围。

foo.service看起来像:

[Unit]
Description=Blah Blah Blah

[Service]
ExecStart=/usr/bar/doof/foo
Type=simple
PIDFile=/var/run/foo.pid

[Install]
WantedBy=multi-user.target,graphical.target
编辑:是的,我确实运行了systemctl daemon-reload

3 个答案:

答案 0 :(得分:13)

来自Google的人:

  • 使用sudo systemd-analyze verify NAME.service
  • 进行验证
  • 使用符号链接时,请确保它使用绝对路径
  • 确保名称与/etc/systemd/system/*.service
  • 相同
  • 更改后sudo systemctl daemon-reload

答案 1 :(得分:3)

我的问题是文件是从另一个分区systemd do not support that.

链接的

Unit files have to reside on a partition that is mounted at the moment the host PID 1 is invoked. i.e. either on the root partition or some other partition that the initrd premounts.

我正在回答一个老问题,因为这是在搜索该问题时的最佳结果,可能会对某人有所帮助

答案 2 :(得分:2)

错误是因为有两个目标指定给WantedBy。只需提一下:

[Install]
WantedBy=multi-user.target

我真的不知道如何为它指定两个目标。