I am trying to run a Node.js app as a service in Debian 9. So, following some tutorials, I've made a service like that.
[Unit] Description=bumer API Http Server [Service] PIDFile=/tmp/bumer-service.pid User=root Group=root Restart=always KillSignal=SIGQUIT WorkingDirectory=/root/bumer/ SyslogIdentifier=bumer ExecStart=/root/bumer/app.js [Install] WantedBy=multi-user.target
My app has
#!/usr/bin/env node as its first line and it runs pretty well if I run the command
The problem is that when I start the service I was getting the following error:
main process exited, code=exited, status=127/n/a
So, I tried to change the first line of the app.js file to the node's path instead of the word "node"
#!/usr/bin/env /usr/local/lib/nodejs/node-v8.11.4/bin/node and now it's running fine.
I guess the service is not reading the PATH variable and I need some help to realize why it doesn't.
(my PATH is right and when I run "type node" the result is OK).
root@bumer:~# type node node is /usr/local/lib/nodejs/node-v8.11.4/bin/node
(I am logging the variable PORT which I set on ~/.bashrc on the app.js but it cannot read as well, it logs