diff options
author | Unknwon <u@gogs.io> | 2015-08-18 23:36:08 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-08-18 23:36:08 +0800 |
commit | 6fdc881bd4ffb0a97a9a3f6ec65182575c5b0bde (patch) | |
tree | 0b06299c0b2a35edc846d8008e82a322459fb19a | |
parent | c20ae8edc515b4d2bd8e8206392c811f3af1b08e (diff) | |
download | gitea-6fdc881bd4ffb0a97a9a3f6ec65182575c5b0bde.tar.gz gitea-6fdc881bd4ffb0a97a9a3f6ec65182575c5b0bde.zip |
detect kill signal
-rw-r--r-- | cmd/web.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cmd/web.go b/cmd/web.go index c441e91966..84def2a481 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -12,6 +12,7 @@ import ( "net/http" "net/http/fcgi" "os" + "os/signal" "path" "strings" @@ -530,6 +531,16 @@ func runWeb(ctx *cli.Context) { // Not found handler. m.NotFound(routers.NotFound) + // Detect kill signal. + c := make(chan os.Signal, 1) + signal.Notify(c, os.Interrupt) + go func() { + for _ = range c { + fmt.Println("Kill signal detected, exiting now...") + os.Exit(0) + } + }() + // Flag for port number in case first time run conflict. if ctx.IsSet("port") { setting.AppUrl = strings.Replace(setting.AppUrl, setting.HttpPort, ctx.String("port"), 1) |