Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using nohup for Node.js on Amazon ec2

I am trying to get my Node app running reliably from an amazon ec2 instance. I have tried:

  1. to install forever I get a ton of errors:

    npm ERR! Error: ENOENT, ... 50 lines of errors ... npm ERR! fstream_stack Object.oncomplete (fs.js:96:15)

  2. nohup node server.js &

Method 2 works but it doesn't start my app again if it goes down. Can someone show me how to use nohup to also restart the app if it goes down? Thanks!

like image 461
SOUser Avatar asked Aug 27 '26 16:08

SOUser


1 Answers

maybe you can try with supervisor:

https://github.com/isaacs/node-supervisor

Quite simple, if something goes wrong it just restart.

For a more complex control, including server restart you can try pm2

https://github.com/Unitech/pm2

pm2 is amazing!!

like image 142
jgato Avatar answered Aug 30 '26 04:08

jgato



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!