K
K
kealman2014-03-12 11:50:42
Software Deployment
kealman, 2014-03-12 11:50:42

How to properly restart applications on Node.js?

Good afternoon. Actually, the subject, how to properly restart the node during deployment, if the application is constantly processing something? For example, connections are constantly open or from a rabbit endlessly come to process a message, and even calculations are going on.
Are there any tools for seamless deployment? Everything that I have googled so far boils down to the fact that you need to write your own shutdown, which will stop all handlers and restart, but this is a drawdown in time, as I think. If, for example, some action takes several seconds, then while it is being completed, the application will not actually work, waiting for a restart. Or maybe someone will share their deployment methods. Thanks in advance for your replies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rumkin, 2014-03-12
@kealman

I believe that seamless deployment is real and convenient in the presence of a third party, let's call it a switcher. How it works:
1. Switcher launches n-instances and starts distributing requests in an even layer between them: keeping a record of requests through counters.
2. You send a reboot/deploy signal to the switcher.
3. Switcher starts to raise new instances without killing the old ones and send requests to them.
4. When the request counter of the old instance is reset, it can be killed, which is what the switcher does.
This way you won't have to modify your existing code, and scaling will be painless by adding new instances. Note that the process has an 'exit' event, on which you hang handlers to stop calculations. Those. first, the external interface is closed in normal mode, and only then internal operations are stopped, connections are closed, locks are released, etc.

I
Ivan Starkov, 2014-03-12
@icelaba

Try https://github.com/amscanne/huptime
I tested it somehow - it feels like it works :-)
Or you can manually describe the process here blog.argteam.com/coding/hardening-node-js-for-prod.. .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question