0

I had installed the node js, express js and npm to manage my application. i have created the app using express js. Now I want to the run my express js app in command line in linux. currently i'm using DEBUG=alpha-webtorrent:* npm start to run my app.

I also want to run my app in background for forever.

Rakesh
  • 213
  • 6
  • 22
  • You have [__`forever`__](https://www.npmjs.com/package/forever) module for that very purpose... – Rayon Nov 24 '16 at 10:07

2 Answers2

2

In your command line run npm install -g pm2 cd o your app,lication and run pm2 start app.js viola your server will run forever and restart if a crash occurs. Documentation for pm2 is here

Dennington-bear
  • 1,732
  • 4
  • 18
  • 44
  • it is not working for me command used forever --minUptime 100 --spinSleepTime 20 start app.js i called the app.js with app.get(/send file) not working – Rakesh Nov 24 '16 at 10:23
0

install a package called forever

npm install forever -g

Go through the documentation to know more about it. https://www.npmjs.com/package/forever

And then use

forever start filename.js
Rohail Najam
  • 1,031
  • 1
  • 8
  • 11