Skip to content

Commit

Permalink
Merge branch 'feature/GracefulStop' into 'master'
Browse files Browse the repository at this point in the history
implement graceful stop using GracefulStop

See merge request !81
  • Loading branch information
timfeirg committed Apr 17, 2017
2 parents 7701415 + 300da63 commit cb01060
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.28a
0.7.29
15 changes: 7 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ var (
logLevel string
)

func waitSignal() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT, syscall.SIGHUP, syscall.SIGKILL, syscall.SIGTERM, syscall.SIGQUIT)
<-c
log.Info("Terminating...")
}

func setupLog(l string) error {
level, err := log.ParseLevel(l)
if err != nil {
Expand Down Expand Up @@ -106,7 +99,13 @@ func serve() {
go http.ListenAndServe(":46656", nil)

log.Info("Cluster started successfully.")
waitSignal()

// wait for unix signals and try to GracefulStop
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGHUP, syscall.SIGTERM)
<-sigs
grpcServer.GracefulStop()
log.Info("Terminating...")
}

func main() {
Expand Down

0 comments on commit cb01060

Please sign in to comment.