scapegoat17
scapegoat17

Reputation: 5831

How to run node.js script from systemd service

I have a node.js script in my directory on my raspberry pi /home/pi/my/app/here/app.js

When I navigate using cd my/app/here and run node app.js my script executes without any problems. However, when I try to execute this script from a service in systemd I get an code=exited, status=203/EXEC error.

Here is my service file:

[Unit]
Description=App
After=network.target

[Service]
Type=simple
User=pi
ExecStart=/user/bin/node /home/pi/my/app/here/app.js
WorkingDirectory=/home/pi/my/app/here
Restart=on-failure

[Install]
WantedBy=multi-user.target

This is really my first time using systemd and most of what I have found has been through research online and other SO posts. So I am sure I am missing something pretty silly, but any help on getting my service to run would be much appreciated.

What am I missing here?

Upvotes: 0

Views: 2440

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190976

Put a hash bang in the file

#!/usr/bin/env node

And just ensure the x bit is set.

Upvotes: 1

Related Questions