可执行路径不是绝对路径,忽略:$(哪个节点)

Jon*_*onB 6 linux debian systemd

这个想法是使用指向节点的变量而不是硬编码的路径,我的解决方案是 ExecStart="$(which node)" /home/jonma/Development/chewy

但是,当我运行该服务时,出现以下错误:

feb 08 11:12:51 jonma-VirtualBox systemd[1]: [/lib/systemd/system/chewy.service:2] Executable path is not absolute, ignoring: $(which node) /home/jon
feb 08 11:12:51 jonma-VirtualBox systemd[1]: chewy.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Run Code Online (Sandbox Code Playgroud)

如何在不对路径进行硬编码的情况下实现这一目标?

ale*_*vag 8

systemd 不会接受没有绝对路径的命令,因此要实现所需的功能,您需要依靠bash-ism并执行以下任一操作:

ExecStart=/bin/bash -c '$$(which node) /home/jonma/Development/chewy'

要么

ExecStart=/bin/bash -c '`which node` /home/jonma/Development/chewy'

(我更喜欢第一个,但您可以做任何事)