start node js server at debian start up

33 views
Skip to first unread message

Raphael AWATE

unread,
Mar 5, 2018, 11:37:34 PM3/5/18
to nodejs
Hello,
I need help to make node js server starting at the server start up.

my server.js is at the localion /home/adminuser/ergo/server.js
 but I normally need to run  "node server.js" inside the  /home/adminuser/ergo/ folder to have it work.

i have spent hours trying various solutions on the internet without success.

Thanks in advance for help. i need to mention that I'm new to linux server and node js.

Thanks again.

Sameer Joshi

unread,
Mar 14, 2018, 10:45:01 AM3/14/18
to nodejs
Hi Raphael,

You can use 'pm2' (https://www.npmjs.com/package/pm2) to manage your node processes.

1. Start the node applications from pm2 instead of vanilla node

pm2 start server.js --name=someName

2. Use the startup command (http://pm2.keymetrics.io/docs/usage/startup/) to create a startup script with

pm2 startup

3. The above command will give you a new command (depending on your OS) to execute as sudo. Just copy, paste and execute that command

4. After this freeze your node process with

pm2 dump

This should do it!
Reply all
Reply to author
Forward
0 new messages