Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Add control+c or INT handling

Chris Lu7e0ae72b0769
diff --git a/go/weed/volume.go b/go/weed/volume.go
index 43cff9ccf9..fa09eb6b5a 100644
--- a/go/weed/volume.go
+++ b/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())
}