0

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?

scapegoat17
  • 5,509
  • 14
  • 55
  • 90
  • 1
    A typo in /user/bin/node – Philippe Mar 26 '22 at 02:03
  • ugh it did end up being a typo... `/usr` instead of `/user`. Thank you! – scapegoat17 Mar 26 '22 at 02:09
  • From the tag: systemd questions should be for *programming questions* using systemd or its libraries. Questions about *configuring the daemon* (including writing unit files) are better directed to Unix & Linux: https://unix.stackexchange.com. – Rob Mar 26 '22 at 10:05

1 Answers1

1

Put a hash bang in the file

#!/usr/bin/env node

And just ensure the x bit is set.

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • It actually seemed to be a issue with me having `/user` which is a type and should be `/usr`. What does the hash bang do for the file? – scapegoat17 Mar 26 '22 at 02:10