Commit 3addc5c
authored
Fix non-graceful server shutdowns and improve signal handling (#41)
* fix: replace os.system() with subprocess.call()
https://docs.python.org/3/library/subprocess.html#replacing-os-system
os.system() ignores SIGINT, which is the stop signal set by the Dockerfile.
This fix should immediately kill the Reforger process upon being asked to stop.
* feat: send SIGTERM to reforger when stopping
This provides a chance for the Reforger process to cleanup.
* feat: kill Reforger process on unhandled exception
If an unknown exception or a second interrupt occurs,
ensure the process is killed.
* feat: propagate exit code from Reforger process
* feat: handle SIGTERM on launch.py
This allows omitting STOPSIGNAL from Dockerfile.
* fix: use shlex.join() when printing command
This ensures the command can actually be invoked by the user
in case some of the arguments contain whitespace or other
unsafe characters.
* fix: stop reforger using SIGINT instead of SIGTERM
* refactor: explicitly skip kill clause when raising SystemExit
The purpose of this is making the program flow more obvious,
since proc.kill() already does nothing on completed processes.1 parent 01eb9f4 commit 3addc5c
1 file changed
+38
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
0 commit comments