Search code examples
node.jsdockerkubernetesuncaught-exception

What to do if node server falls down in container?


If an uncaughtException occurs in Docker container running node app which is wrapped by Kubernetes Pod and due to this exception the server gets down, what should I do?


Solution

  • If you use ReplicaSet (Deployment is also a ReplicaSet), then after the application crashes, the pod will also crash, as a result of which the ReplicaSet will create a new pod.

    PS: I think it's obvious that uncaughtException occurs when there are uncaught exceptions in your code (not in promises and async/await). To prevent this event from being raised, you need to add exception handlers wherever exceptions might be thrown.