Hello, if we have an error, nodemon wait file modification or manually rs command but I run command in production server and I can not afford to let the server down for even just a few minutes. Would it be possible to add an option to automatically restart the server without any external help?
Do you mean like the forever module?
On 23 May 2013 15:08, Benjamin Besse [email protected] wrote:
Hello, if we have an error, nodemon wait file modification or manually rs
command but I run command in production server and I can not afford to let
the server down for even just a few minutes. Would it be possible to add an
option to automatically restart the server without any external help?—
Reply to this email directly or view it on GitHubhttps://github.com/remy/nodemon/issues/175
.
Yes,i mean like the 'forever' module if it's possible :+1:
I'd love to see this too; a general restart on exit (error or clean). I know... forever... but...
For local dev scripts that I don't care to add error handling and fancy stuff, nodemon --auto-restart some-crappy-proxy.js would make life easier.
Maybe call it --dev-restart or something that makes it obvious it's not a forever replacement?
yep, this makes sense.. +1. It helps especially in the development env
Not sure if I missed it, or it was recently added, but nodemon has --exitcrash now.
I think forever nodemon --exitcrash blah.js gets us all where we want to be? A bit cumbersome, but w/e.
Nodemon is only meant for development. This will restart app.js whenever it exits:
while true; do node app.js; echo "Crashed. Restarting..."; done
But I would recommend learning about pm2 or forever for running apps in production.
What @mcjohnalds said
The following set of npm scripts will mimic what nodemon is doing, but using PM2:
"scripts": {
"log": "./node_modules/.bin/pm2 log",
"reset": "yarn run stop && ./node_modules/.bin/pm2 delete all && ./node_modules/.bin/pm2 flush",
"start": "yarn run watch && yarn run log",
"stop": "./node_modules/.bin/pm2 stop all",
"watch": "./node_modules/.bin/pm2 start src/index.js --watch --interpreter ./node_modules/.bin/babel-node"
}
PM2's --interpreter flag is similar to nodemon's --exec flag. Here I am using it to run babel-node
is it done ? I'd loooove the option, mostly on intended errors like: throw new Error()
Any updates on this in 2020?
Having the ability for it to restart on an error would be great, preferably with the delay.
I t would be good to have a config option, not just a command line argument.
Yes, there was: https://github.com/remy/nodemon/issues/175#issuecomment-335336592
Most helpful comment
Not sure if I missed it, or it was recently added, but nodemon has
--exitcrashnow.I think
forever nodemon --exitcrash blah.jsgets us all where we want to be? A bit cumbersome, but w/e.