Skip to content

Commit

Permalink
capturing only os.Interrupt for graceful shutdown
Browse files Browse the repository at this point in the history
 - os package provides a platform-independent interface
 - os.Kill cannot be captured, so only capturing os.Interrupt
  • Loading branch information
AndersonQ committed May 29, 2020
1 parent 805c6f8 commit c4a3ebf
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"net/http"
"os"
"os/signal"
"syscall"
"time"

"github.com/go-chi/chi"
Expand All @@ -24,8 +23,7 @@ import (
func main() {
// catch the signals as soon as possible
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, syscall.SIGINT) // a.k.a ctrl+C
signal.Notify(signalChan, syscall.SIGTERM) // a.k.a kill
signal.Notify(signalChan, os.Interrupt) // a.k.a ctrl+C

// when closed the program should exit
idleConnsClosed := make(chan bool)
Expand Down

0 comments on commit c4a3ebf

Please sign in to comment.