Browse Source

Add control+c or INT handling

pull/2/head
Chris Lu 11 years ago
parent
commit
7e0ae72b07
  1. 12
      go/weed/volume.go

12
go/weed/volume.go

@ -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…
Cancel
Save