Wikia/mercury — pull request #208 by aquilax (2014-09-29 13:00:27+00:00)
Title: HG-172: Decreased the service restart timeout

Make the service stop gracefully ASAP after `SIGTERM`.

Master now sends to all workers `shutdown` message on `SIGTERM`, when the workers receives the event, it calls `Hapi.Server.stop()`

Introduced new value to config `workerDisconnectTimeout` with default value 3000 ms.
It is used as timeout value for `Hapi.Server.stop` (which by default timeouts after 5000 ms) and in `server.js` for waiting the worker to disconnect.

Some non conclusive tests on laptop with 7 workers:

- 16ms from master receiving `SIGTERM` to last worker disconnected and shutdown, when no clients are connected;
- 93 ms from master receiving `SIGTERM` to last worker disconnected and shutdown, in the middle of ` ab -n 1000 -c 10 [url]`