0

I have NodeJS app. app.js. And I'm trying to start it at each boot of my linux device. For that here what I've tried :

myshell.sh

#!/bin/bash

SCRIPT=/home/root/MYAPP/
RUNAS=root
start() {
    node /home/root/MYAPP/app.js
}

stop() {

}

placing this shell in /etc/init.d/ doesn't solve it. So my question is how may add my app.js as added startup service ?
thanks in advance!

  • The really easy option would be to start it with cron as a @reboot job. I wouldn't know how to do it with systemd though. – Kusalananda Nov 7 at 9:30
  • @Kusalananda thanks for replying. if u have an example on how to do I'll try it – Engine Nov 7 at 9:35
1

Of course, you could write your own systemd unit starting NodeJS based processes. THen again, you may want to look into NodeJS Processes Managers, such as PM2.

You'll find all you need registering a systemd service, then managing your NodeJS processes : https://pm2.keymetrics.io/docs/usage/startup/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.