Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to auto restart on error #175

Closed
throrin19 opened this issue May 23, 2013 · 11 comments
Closed

Add option to auto restart on error #175

throrin19 opened this issue May 23, 2013 · 11 comments

Comments

@throrin19
Copy link

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?

@remy
Copy link
Owner

remy commented May 23, 2013

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//issues/175
.

@throrin19
Copy link
Author

Yes,i mean like the 'forever' module if it's possible 👍

@cmawhorter
Copy link

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?

@madhums
Copy link

madhums commented Sep 18, 2014

yep, this makes sense.. +1. It helps especially in the development env

@cmawhorter
Copy link

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.

@mcjohnalds
Copy link

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.

@remy
Copy link
Owner

remy commented Oct 10, 2017

What @mcjohnalds said

@remy remy closed this as completed Oct 10, 2017
@d4nyll
Copy link

d4nyll commented Oct 26, 2017

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

@axe-z
Copy link

axe-z commented Dec 5, 2018

is it done ? I'd loooove the option, mostly on intended errors like: throw new Error()

@GoodClover
Copy link

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.

@remy
Copy link
Owner

remy commented Oct 21, 2020

Yes, there was: #175 (comment)

Repository owner locked as resolved and limited conversation to collaborators Oct 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants