Browse Source

detect kill signal

tags/v1.2.0-rc1
Unknwon 9 years ago
parent
commit
d2a6c63f37
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      cmd/web.go

+ 11
- 0
cmd/web.go View File

@@ -12,6 +12,7 @@ import (
"net/http" "net/http"
"net/http/fcgi" "net/http/fcgi"
"os" "os"
"os/signal"
"path" "path"
"strings" "strings"


@@ -530,6 +531,16 @@ func runWeb(ctx *cli.Context) {
// Not found handler. // Not found handler.
m.NotFound(routers.NotFound) 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. // Flag for port number in case first time run conflict.
if ctx.IsSet("port") { if ctx.IsSet("port") {
setting.AppUrl = strings.Replace(setting.AppUrl, setting.HttpPort, ctx.String("port"), 1) setting.AppUrl = strings.Replace(setting.AppUrl, setting.HttpPort, ctx.String("port"), 1)


Loading…
Cancel
Save