mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-15 20:06:19 +08:00
better handling of os signals
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"runtime/pprof"
|
||||
"strconv"
|
||||
@@ -218,16 +217,10 @@ func runServer(cmd *Command, args []string) bool {
|
||||
glog.Fatalf(e.Error())
|
||||
}
|
||||
|
||||
// deal with control+c
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, os.Interrupt, os.Kill)
|
||||
go func() {
|
||||
for _ = range signalChan {
|
||||
volumeServer.Shutdown()
|
||||
pprof.StopCPUProfile()
|
||||
os.Exit(0)
|
||||
}
|
||||
}()
|
||||
OnInterrupt(func() {
|
||||
volumeServer.Shutdown()
|
||||
pprof.StopCPUProfile()
|
||||
})
|
||||
|
||||
if e := http.Serve(volumeListener, r); e != nil {
|
||||
glog.Fatalf("Fail to serve:%s", e.Error())
|
||||
|
Reference in New Issue
Block a user