'best way to gracefully shutdown process running on Google Cloud VM
I'm running a blockchain node validator in a GCP ubuntu vm and need to shut it down so I can restart it.
What's the best way to stop just the validator, and not the entire vm?
The blockchain docs recommends stopping the running client (through a service manager or some mechanism that sends a SIGINT signal to the process), so it can trigger 2 events while gracefully shutting down:
- Running data flush to disk
- Release of the DB files lock by LevelDB
However the docs do not explain how to do this.
Solution 1:[1]
To send a signal to a program on Linux use the kill command:
kill <SIGNAL> <PID>
To list the running processes:
ps -axl
Look up the name of your program in the process list.
Common signals to set to programs are SIGHUP (1) and SIGINT (2). SIGKILL (9) is a forced terminate and the program cannot catch this signal.
Look up in their documentation which signal they use. You mentioned SIGINT.
kill 2 <PID>
or
kill SIGINT <PID>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Hanley |
