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

问题描述 投票:3回答:1

我的想法是使用指向节点而不是硬编码路径的变量,我的解决方案是这个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.

如何在没有硬编码路径的情况下实现这一目标?

linux debian systemd
1个回答
6
投票

systemd不会接受没有绝对路径的命令,所以要完成你想要的东西,你需要依赖bash-ism并执行以下操作之一:

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

要么

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

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

© www.soinside.com 2019 - 2024. All rights reserved.