Tuesday 23 June 2020

[Ask] What Is The Convention For Gracefully Restarting NodeJS In Docker?

If my NodeJS app constantly restarts, what service should I be using within Docker?pm2-runtime (https://pm2.keymetrics.io/docs/usage/docker-pm2-nodejs/)nodemon (don't really think this is the right solution)rely on Docker/Kubernetes to restart the containerOther​Bonus question, if anyone has implemented this before, would love to know the reason why they chose this convention/tool/way and if there are any drawbacks.​Following the convention from:The best way to recover from programmer errors is to crash immediately. You should run your programs using a restarter that will automatically restart the program in the event of a crash. With a restarter in place, crashing is the fastest way to restore reliable service in the face of a transient programmer error.- https://www.joyent.com/node-js/production/design/errors​Also assuming, in my main file that I would have something like the following:process.on('uncaughtException', (e) => { // Code + Logging Here process.exit(1); }); process.on('unhandledRejection', (e) => { // Code + Logging Here process.exit(1); });

Submitted June 23, 2020 at 09:12PM by codingwithmanny

No comments:

Post a Comment