I have a very, very busy node application on a production server. The app
deals with a real-time chat (using websockets) as well as e-commerce
payments. While *everything* is absolutely set so that when the server goes
down the clients will reconnect their sockets etc., I still have a problem:
whenever the server is stopped, with a SIGINT, the event loop is cut off.
This means that any pending DB write (possibly for a financial transaction)
is simply discarded. There are two especially crucial moments (when the
credit card merchant gives the OK, but *before* we write the record on the
db) and at the moment we are shutting it down at off-peak times to prevent
any possible problems. But this is bad.
I am thinking of this as a solution:
- I send a custom UNIX signal to the process (SIGUSR2 for example?);
- When server.js gets the signal:
- It stops listening to port 80
- It waits for the event loop to dry up
- If after 10 seconds it's still hanging, it forces the closure This
means that at each reboot the server will be at the most down for 10
seconds.
Is this what people in the real world do? Any gotcha? How do I check that
the event loop is empty?
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/2058de6b-d042-4e82-b3ea-b1379e9d721e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.