mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Add control+c or INT handling
This commit is contained in:
parent
982aaa41b9
commit
7e0ae72b07
|
@ -78,7 +78,7 @@ func runVolume(cmd *Command, args []string) bool {
|
|||
|
||||
r := http.NewServeMux()
|
||||
|
||||
weed_server.NewVolumeServer(r, *ip, *vport, *publicIp, folders, maxCounts,
|
||||
volumeServer := weed_server.NewVolumeServer(r, *ip, *vport, *publicIp, folders, maxCounts,
|
||||
*masterNode, *vpulse, *dataCenter, *rack, volumeWhiteList,
|
||||
)
|
||||
|
||||
|
@ -91,6 +91,16 @@ func runVolume(cmd *Command, args []string) bool {
|
|||
glog.Fatalf(e.Error())
|
||||
}
|
||||
|
||||
// deal with control+c
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, os.Interrupt)
|
||||
go func() {
|
||||
for _ = range signalChan {
|
||||
volumeServer.Shutdown()
|
||||
os.Exit(0)
|
||||
}
|
||||
}()
|
||||
|
||||
if e := http.Serve(listener, r); e != nil {
|
||||
glog.Fatalf("Fail to serve:%s", e.Error())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue