Hey!
I have a project that sometimes crashes. I use a third party lib that sometimes fails startup, and my way to handle that in production is to do process.exit(1), and wait for docker to start up a new instance until it works.
But for development we use nodemon. What I would really like is if it were possible to have nodemon automatically restart whenever the program crashes (even without code changes).
Basically, now it looks like this:
[nodemon] app crashed - waiting for file changes before starting...
What I want is this:
[nodemon] app crashed - restarting in 2 seconds
Or maybe this:
[nodemon] app crashed - restarting...
I saw this: "new command line options are generally discouraged unless there's a really good reason"
But I guess this functionality should be behind a command line option.
Is this a resonable request? If so, I might find time to put together a PR
I think you're better off looking at pm2, supervisord or forever @lulzmachine, as these are designed for monitoring, managing and automatically restarting processes. Perhaps @remy will disagree, but I feel like this isn't the goal of the nodemon
project and more the goal of some of those (and probably more) I've listed.
Well nodemon already does all the steps that I want. I just want to short-circuit out the "waiting for changes" part. To be clear, I also want to restart on code changes, but also whenever the application exits
Having the same problem. It used to work when I was using the script
option, but I had to switch to exec
now to use typescript and now it does not restart on crash.
Was this option remove from nodemon
@remy? I am pretty sure it used to work. Do we have to use forever
with nodemon
to get it to restart on crashes?
This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up.
Thank you for contributing <3
Most helpful comment
Well nodemon already does all the steps that I want. I just want to short-circuit out the "waiting for changes" part. To be clear, I also want to restart on code changes, but also whenever the application exits