我的想法是使用指向节点而不是硬编码路径的变量,我的解决方案是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.
如果不对路径进行硬编码,我怎样才能实现这一目标?
答案 0 :(得分:4)
systemd
将不接受未通过绝对路径指定的命令,因此要完成您想要的任务,您需要依赖bash-ism并执行以下操作之一:
ExecStart=/bin/bash -c '$$(which node) /home/jonma/Development/chewy'
或
ExecStart=/bin/bash -c '`which node` /home/jonma/Development/chewy'
(我喜欢第一个更好,但你可以做任何事情)