0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-22 02:04:16 +01:00

detect kill signal

This commit is contained in:
Unknwon 2015-08-18 23:36:08 +08:00
parent c20ae8edc5
commit 6fdc881bd4

View file

@ -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)