我的想法是使用指向节点而不是硬编码路径的变量,我的解决方案是这个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.
如何在没有硬编码路径的情况下实现这一目标?
systemd
不会接受没有绝对路径的命令,所以要完成你想要的东西,你需要依赖bash-ism并执行以下操作之一:
ExecStart=/bin/bash -c '$$(which node) /home/jonma/Development/chewy'
要么
ExecStart=/bin/bash -c '`which node` /home/jonma/Development/chewy'
(我喜欢第一个更好,但你可以做任何事)