When Redis is not reachable upon main() execution, it happens before process.on('cleanup', () => {...}) is wired.
The result is a stale hydra-router that cannot be collected by the container, thus cannot be restarted.
This splits the try/catch block in 2, the first block will immediately process.exit(1);.
The second will trigger process.emit('cleanup') upon an exception and that will be handled by the listener, properly shutdown the service.
When Redis is not reachable upon
main()
execution, it happens beforeprocess.on('cleanup', () => {...})
is wired. The result is a stalehydra-router
that cannot be collected by the container, thus cannot be restarted.This splits the
try/catch
block in 2, the first block will immediatelyprocess.exit(1);
. The second will triggerprocess.emit('cleanup')
upon an exception and that will be handled by the listener, properly shutdown the service.