3

I have a microservice running in kubernetes with deployment. It is serving a Node JS application with PM2. I recently found whenever I deploy a new version of application with helm, i can see PM2 is being exited with code [0]

PM2 log: App [api.bundle:0] exited with code [0] via signal [SIGINT]

I tried to investigate if there is an exception in application. Could not found any error prior deployment. That leads me to ask if how pm2 is getting restarted? Does kubernetes sends kill signal to pm2 if an new deployment comes in?

Timam
  • 378
  • 1
  • 2
  • 8
  • 1
    You shouldn't need pm2; the container environment manages many of the some concerns such as restarting the application (Kubernetes Pod) if it fails. Also see [what is the point of using pm2 and docker together?](https://stackoverflow.com/questions/51191378/what-is-the-point-of-using-pm2-and-docker-together) – David Maze Jun 21 '22 at 23:54
  • Thanks for sharing, reading "what is the point of using pm2 and docker together" looks like pm2 is not needed. – Timam Jun 22 '22 at 07:56

2 Answers2

2

...whenever I deploy a new version of application with helm, i can see PM2 is being exited with code [0]

When you do helm upgrade the command triggers rolling update to the deployment which replace existing pod(s) with new pod. During this process, signal [SIGINT] was sent to inform your PM2 container it's time to exit.

...if how pm2 is getting restarted? Does kubernetes sends kill signal to pm2 if an new deployment comes in?

Correct.

gohm'c
  • 13,492
  • 1
  • 9
  • 16
0

First it will send TERM signal after grace period it will send KILL. Please refer kubernetes documentation for more details

Nataraj Medayhal
  • 980
  • 1
  • 2
  • 12