Skip to content
Myr

add notify accept signal (#1740)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* add notify accept signal * add import * update readme,keep same with example

authored by awkj · committed by 田欧 · parent 31bbb10 · Browse files · 2 files+10 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−2 removed

  • other:+10 added−2 removed

2 files+10 added−2 removed

modified:examples/graceful-shutdown/graceful-shutdown/server.go+5 added-1 removed
6 unmodified lines
7 "log"8 "net/http"9 "os"10 "os/signal"11 "syscall"12 "time"1314 "github.com/gin-gonic/gin"15)
19 unmodified lines
3536 // Wait for interrupt signal to gracefully shutdown the server with37 // a timeout of 5 seconds.38 quit := make(chan os.Signal)38 signal.Notify(quit, os.Interrupt)39 // kill (no param) default send syscanll.SIGTERM40 // kill -2 is syscall.SIGINT41 // kill -9 is syscall. SIGKILL but can"t be catch, so don't need add it42 signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)43 <-quit44 log.Println("Shutdown Server ...")4546 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
6 unmodified lines
modified:README.md+5 added-1 removed
1631 unmodified lines
1632 "log"1633 "net/http"1634 "os"1635 "os/signal"1636 "syscall"1637 "time"16381639 "github.com/gin-gonic/gin"1640)
19 unmodified lines
16601661 // Wait for interrupt signal to gracefully shutdown the server with1662 // a timeout of 5 seconds.1663 quit := make(chan os.Signal)1663 signal.Notify(quit, os.Interrupt)1664 // kill (no param) default send syscanll.SIGTERM1665 // kill -2 is syscall.SIGINT1666 // kill -9 is syscall. SIGKILL but can"t be catch, so don't need add it1667 signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)1668 <-quit1669 log.Println("Shutdown Server ...")16701671 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
379 unmodified lines