Reputation: 398
I know I can run Node.js on server with command line node app.js
.
But when I am out of control server, the session will be close and end my command. I don't know how to make a service run Node.js 24/7 like another in Server.
I follow this post, but I'm not using express.
Upvotes: 3
Views: 3074
Reputation: 6168
You can make it happen by many ways.
You can append &
in the command line to make the node server run in background.
node app.js > stdout.txt > stderr.txt &
Via process manager pm2, It gives more features, you can monitor all the processes pm2 monit
, auto restart, etc
npm install pm2 -g
pm2 start app.js
or, using following npm packages
Nodemon - nodemon app.js
Forever - forever start app.js
.
Upvotes: 2
Reputation: 309
run it using forever , it helps the server to restart whenever the node server get crashed. https://www.npmjs.com/package/forever
Upvotes: 3