When Redis is not reachable upon start() execution, it happens before process.on('cleanup', () => {...}) is wired.
The result is a stale hydra-express that cannot be collected by the container, thus cannot be restarted.
In this case a Docker HEALTHCHECK or a Kubernetes livenessProbe for the deployment/.../container could help terminating and starting a new deployment.
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
start()
execution, it happens beforeprocess.on('cleanup', () => {...})
is wired. The result is a stalehydra-express
that cannot be collected by the container, thus cannot be restarted.In this case a Docker
HEALTHCHECK
or a KuberneteslivenessProbe
for the deployment/.../container could help terminating and starting a new deployment.This splits the try/catch block in 2, the first block will immediately
process.exit(1);
. The second will triggerprocess.emit('cleanup')
upon an exception and that will be handled by the listener, properly shutdown the service.