Commit 31d036e
committed
fix: handle SIGTERM gracefully on unix
We weren't catching SIGTERM and cancelling our context, so the go
runtime would have us exit with a non-zero code when the signal was
received. Let's catch it and try to exit gracefully.
i.e. before:
(...)
I0508 11:08:00.426917 1787442 log_monitor.go:237] Initialize condition generated: []
^C
$ echo $?
130
and now:
(...)
I0508 11:07:42.150562 1787146 log_monitor.go:237] Initialize condition generated: []
^C
I0508 11:07:43.372093 1787146 log_monitor.go:123] Stop log monitor /tmp/npd-test.json
I0508 11:07:43.652876 1787146 log_watcher.go:104] Stop watching filelog
I0508 11:07:43.652923 1787146 log_monitor.go:144] Log monitor stopped: /tmp/npd-test.json
$ echo $?
01 parent 653620a commit 31d036e
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
57 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
58 | 63 | | |
59 | 64 | | |
60 | 65 | | |
0 commit comments