Exec node unable to launch service

Hi guys, from previous issues, im trying to run a ffmpeg command as a service...
If I execute from command line, it works like a charm:

pi@pi2:~ $ systemctl --user start myscript

But, when I execute it from exec node I got:

Failed to connect to bus: No existe el fichero o el directorio

the flow:

[{"id":"9e05b5cf.bce038","type":"exec","z":"bcea7856.3d9df8","command":"systemctl --user start myservice","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"ffmpeg","x":420,"y":120,"wires":[["ce60718c.630bf"],["ce60718c.630bf"],["ce60718c.630bf"]]},{"id":"72214724.8e5f18","type":"inject","z":"bcea7856.3d9df8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":120,"wires":[["9e05b5cf.bce038"]]},{"id":"ce60718c.630bf","type":"debug","z":"bcea7856.3d9df8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":120,"wires":[]}]

I've read across lots of linux forums and its seems its a issue related to enviroments variables like XDG_RUNTIME_DIR or something.

Would somebody give me any clue about the issue and how to solve it? thx :wink:

When you are at the command line, run the command set. This will show you all of the environment variables you get from a standard command prompt. Now run the same command from an exec node and compare the two outputs.

In fact, I assign process.env to a global variable in my settings.js so that I have them all to hand when working with Node-RED (though note that you shouldn't do this if running in a shared environment as there can be quite sensitive things kept as environment variables). However, also note that the result of a set in an exec node might not be quite the same.

Now you can add the variables you need to the exec command you are running.

1 Like

Now I hadded ${XDG_RUNTIME_DIR} environment variable. And the error has changed to:

Failed to start myservice.service: Unit myservice.service not found.

Maybe other variables are needed, but I doesnt know witch of them.

Does it say exactly that or have you changed the actual name?
Where have you put the service file?

Hi @Colin,
Says exactly this, the script is located here (added 777 permissions temporally):

/home/pi/.config/systemd/user/myscript.service

When I run it from command line it works, these make me assume that the service is properly configured.

You have got the name wrong. You are trying to start myservice, but it is called myscript.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.