-1

I'm very new to server related stuff, but I'm trying to have a node.js server start automatically in a TrueNAS jail upon booting up (instead of starting the server manually through the terminal).

The most promising thing I could find is adding some kind of script to run at startup in the /etc/rc.d directory, but I couldn't find any specific information on running a node.js server from it. Sorry if that doesn't make any sense at all.

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Feb 01 '22 at 10:23

1 Answers1

0

M'kay I found a solution. For anyone else who's curious there's an npm package called pm2 that does exactly what I was trying to do. Here's how I got it working:

Install pm2: npm install pm2 -g

Make pm2 run on startup: pm2 startup

If you get an error that says Faliure when trying to write startup script then enter the command: mkdir /usr/local/etc/rc.d to create the directory it's looking for, then run pm2 startup again and it should work

Then start your node.js app: pm2 start app.js

Finally run pm2 save to automatically start your app whenever the jail boots up