pnxtech / hydra-router

A service aware router for Hydra Services. Implements an API Gateway and can route web socket messages.
MIT License
60 stars 26 forks source link

End main process if redis is unavailable at boot #193

Closed tomascasas closed 2 years ago

tomascasas commented 2 years ago

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.