Skip to content

Commit 45603d8

Browse files
committed
feat(main): cleanup on signal SIGTERM
1 parent 01f4f07 commit 45603d8

39 files changed

+63
-63
lines changed

src/main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"syscall"
1212
)
1313

14-
func cleanupOnInterrupt(appInst *app.App) {
14+
func cleanupOnEnd(appInst *app.App) {
1515
chSignal := make(chan os.Signal)
16-
signal.Notify(chSignal, syscall.SIGINT)
16+
signal.Notify(chSignal, syscall.SIGINT, syscall.SIGTERM)
1717

1818
go func() {
1919
<-chSignal
@@ -22,7 +22,7 @@ func cleanupOnInterrupt(appInst *app.App) {
2222
}()
2323
}
2424

25-
func reOpenLogOnHup(appInst *app.App) {
25+
func reopenLogOnHup(appInst *app.App) {
2626
chSignal := make(chan os.Signal)
2727
signal.Notify(chSignal, syscall.SIGHUP)
2828

@@ -53,8 +53,8 @@ func main() {
5353
serverError.CheckFatal(errors.New("failed to create application instance"))
5454
}
5555

56-
cleanupOnInterrupt(appInst)
57-
reOpenLogOnHup(appInst)
56+
cleanupOnEnd(appInst)
57+
reopenLogOnHup(appInst)
5858
errs = appInst.Open()
5959
serverError.CheckFatal(errs...)
6060

test/case/001.basic.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ assert $(curl_head_status 'http://127.0.0.1:3003/escape-escaped%252fslash/') '20
2525
assert $(curl_head_status 'http://127.0.0.1:3003/escape%23sharp') '200'
2626
assert $(curl_head_status 'http://127.0.0.1:3003/escape%25percent') '200'
2727

28-
jobs -p | xargs kill
28+
jobs -p | xargs kill &> /dev/null

test/case/002.vhost.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ assert "$vh1file1" 'vhost1/file1.txt'
1111
vh2file1=$(curl_get_body http://127.0.0.2:3003/file1.txt)
1212
assert "$vh2file1" 'vhost2/file1.txt'
1313

14-
jobs -p | xargs kill
14+
jobs -p | xargs kill &> /dev/null

test/case/003.vhost.tls.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ assert "$vh1file1" 'vhost1/file1.txt'
1111
vh2file1=$(curl_get_body https://127.0.0.2:3003/file1.txt)
1212
assert "$vh2file1" 'vhost2/file1.txt'
1313

14-
jobs -p | xargs kill
14+
jobs -p | xargs kill &> /dev/null

test/case/004.alias.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ assert "$status" '404'
3232
baz=$(curl_get_body http://127.0.0.1:3003/foo/bar/baz/b1.txt)
3333
assert "$baz" 'vhost2/b/b1.txt'
3434

35-
jobs -p | xargs kill
35+
jobs -p | xargs kill &> /dev/null

test/case/005.alias.empty.root.alias.root.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ assert "$file1status" '200'
1111
file1headstatus=$(curl_head_status http://127.0.0.1:3003/file1.txt)
1212
assert "$file1headstatus" '200'
1313

14-
jobs -p | xargs kill
14+
jobs -p | xargs kill &> /dev/null

test/case/005.alias.empty.root.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ assert "$go" 'vhost1/go/index.txt'
2323
yes=$(curl_get_body http://127.0.0.1:3003/not/exist/name/index.txt)
2424
assert "$yes" 'vhost1/yes/index.txt'
2525

26-
jobs -p | xargs kill
26+
jobs -p | xargs kill &> /dev/null

test/case/007.auth.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ assert "$userhellostatus" '200'
1717
userhelloheadstatus=$(curl_head_status http://alice:AliceSecret@127.0.0.1:3003/hello/)
1818
assert "$userhelloheadstatus" '200'
1919

20-
jobs -p | xargs kill
20+
jobs -p | xargs kill &> /dev/null

test/case/008.dir.index.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ sleep 0.05 # wait server ready
88
yes=$(curl_get_body http://127.0.0.1:3003/yes)
99
assert "$yes" 'vhost1/yes/index.txt'
1010

11-
jobs -p | xargs kill
11+
jobs -p | xargs kill &> /dev/null

test/case/009.alias.dir.index.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ sleep 0.05 # wait server ready
88
world=$(curl_get_body http://127.0.0.1:3003/foo)
99
assert "$world" 'vhost1/go/index.txt'
1010

11-
jobs -p | xargs kill
11+
jobs -p | xargs kill &> /dev/null

0 commit comments

Comments
 (0)