Skip to content

Commit

Permalink
ensure app is removed from pool after sigterm (#274)
Browse files Browse the repository at this point in the history
* remove app from pool on shutdown

* add reason to log message

* ignore logs

* go mod tidy, add 1.16 to ci

* don't use circle anymore
  • Loading branch information
nonrational authored Apr 16, 2021
1 parent 4fb2d15 commit 41db297
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/tmp
/coverage*.out
/coverage.html
/*.log

.ruby-version
.tool-versions
Expand Down
8 changes: 7 additions & 1 deletion dev/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,21 @@ func (a *App) Kill(reason string) error {
"reason", reason,
)

fmt.Printf("! Killing '%s' (%d)\n", a.Name, a.Command.Process.Pid)
fmt.Printf("! Killing '%s' (%d) - '%s'\n", a.Name, a.Command.Process.Pid, reason)
err := a.Command.Process.Signal(syscall.SIGTERM)
if err != nil {
a.eventAdd("killing_error",
"pid", a.Command.Process.Pid,
"error", err.Error(),
)
fmt.Printf("! Error trying to kill %s: %s", a.Name, err)
} else {
// sigterm successful -- now that this app is stopped, remove it
// from pool so it is guaranteed be booted on the next request
a.pool.remove(a)
a.eventAdd("shutdown")
}

return err
}

Expand Down

0 comments on commit 41db297

Please sign in to comment.