diff options
Diffstat (limited to 'weed')
| -rw-r--r-- | weed/command/filer_copy.go | 3 | ||||
| -rw-r--r-- | weed/command/master.go | 3 | ||||
| -rw-r--r-- | weed/command/mount_std.go | 5 | ||||
| -rw-r--r-- | weed/command/msg_broker.go | 3 | ||||
| -rw-r--r-- | weed/command/volume.go | 5 | ||||
| -rw-r--r-- | weed/filesys/wfs.go | 7 | ||||
| -rw-r--r-- | weed/server/filer_server.go | 3 | ||||
| -rw-r--r-- | weed/server/webdav_server.go | 3 | ||||
| -rw-r--r-- | weed/util/grace/pprof.go (renamed from weed/util/pprof.go) | 2 | ||||
| -rw-r--r-- | weed/util/grace/signal_handling.go (renamed from weed/util/signal_handling.go) | 2 | ||||
| -rw-r--r-- | weed/util/grace/signal_handling_notsupported.go (renamed from weed/util/signal_handling_notsupported.go) | 2 |
11 files changed, 23 insertions, 15 deletions
diff --git a/weed/command/filer_copy.go b/weed/command/filer_copy.go index 0e9e10ee3..b6ac7854b 100644 --- a/weed/command/filer_copy.go +++ b/weed/command/filer_copy.go @@ -14,6 +14,7 @@ import ( "sync" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "google.golang.org/grpc" "github.com/chrislusf/seaweedfs/weed/operation" @@ -134,7 +135,7 @@ func runCopy(cmd *Command, args []string) bool { copy.ttlSec = int32(ttl.Minutes()) * 60 if *cmdCopy.IsDebug { - util.SetupProfiling("filer.copy.cpu.pprof", "filer.copy.mem.pprof") + grace.SetupProfiling("filer.copy.cpu.pprof", "filer.copy.mem.pprof") } fileCopyTaskChan := make(chan FileCopyTask, *copy.concurrenctFiles) diff --git a/weed/command/master.go b/weed/command/master.go index 7e69f558c..6301c7730 100644 --- a/weed/command/master.go +++ b/weed/command/master.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/chrislusf/raft/protobuf" + "github.com/chrislusf/seaweedfs/weed/util/grace" "github.com/gorilla/mux" "google.golang.org/grpc/reflection" @@ -82,7 +83,7 @@ func runMaster(cmd *Command, args []string) bool { util.LoadConfiguration("master", false) runtime.GOMAXPROCS(runtime.NumCPU()) - util.SetupProfiling(*masterCpuProfile, *masterMemProfile) + grace.SetupProfiling(*masterCpuProfile, *masterMemProfile) if err := util.TestFolderWritable(*m.metaFolder); err != nil { glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err) diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index b1e47809c..2dc9aa196 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -19,13 +19,14 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/security" "github.com/chrislusf/seaweedfs/weed/util" + "github.com/chrislusf/seaweedfs/weed/util/grace" "github.com/seaweedfs/fuse" "github.com/seaweedfs/fuse/fs" ) func runMount(cmd *Command, args []string) bool { - util.SetupProfiling(*mountCpuProfile, *mountMemProfile) + grace.SetupProfiling(*mountCpuProfile, *mountMemProfile) umask, umaskErr := strconv.ParseUint(*mountOptions.umaskString, 8, 64) if umaskErr != nil { @@ -144,7 +145,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { } defer fuse.Unmount(dir) - util.OnInterrupt(func() { + grace.OnInterrupt(func() { fuse.Unmount(dir) c.Close() }) diff --git a/weed/command/msg_broker.go b/weed/command/msg_broker.go index d4d3865fa..984497c2e 100644 --- a/weed/command/msg_broker.go +++ b/weed/command/msg_broker.go @@ -6,6 +6,7 @@ import ( "strconv" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "google.golang.org/grpc/reflection" "github.com/chrislusf/seaweedfs/weed/glog" @@ -57,7 +58,7 @@ func runMsgBroker(cmd *Command, args []string) bool { func (msgBrokerOpt *QueueOptions) startQueueServer() bool { - util.SetupProfiling(*messageBrokerStandaloneOptions.cpuprofile, *messageBrokerStandaloneOptions.memprofile) + grace.SetupProfiling(*messageBrokerStandaloneOptions.cpuprofile, *messageBrokerStandaloneOptions.memprofile) filerGrpcAddress, err := pb.ParseFilerGrpcAddress(*msgBrokerOpt.filer) if err != nil { diff --git a/weed/command/volume.go b/weed/command/volume.go index eab24ca97..6258be6cf 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "github.com/spf13/viper" "google.golang.org/grpc" @@ -93,7 +94,7 @@ func runVolume(cmd *Command, args []string) bool { util.LoadConfiguration("security", false) runtime.GOMAXPROCS(runtime.NumCPU()) - util.SetupProfiling(*v.cpuProfile, *v.memProfile) + grace.SetupProfiling(*v.cpuProfile, *v.memProfile) v.startVolumeServer(*volumeFolders, *maxVolumeCounts, *volumeWhiteListOption) @@ -183,7 +184,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v clusterHttpServer := v.startClusterHttpService(volumeMux) stopChain := make(chan struct{}) - util.OnInterrupt(func() { + grace.OnInterrupt(func() { fmt.Println("volume server has be killed") var startTime time.Time diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index e7d1766b6..33403aaf8 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -10,6 +10,7 @@ import ( "sync" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "github.com/karlseguin/ccache" "google.golang.org/grpc" @@ -89,18 +90,18 @@ func NewSeaweedFileSystem(option *Option) *WFS { } if option.CacheSizeMB > 0 { wfs.chunkCache = chunk_cache.NewChunkCache(256, option.CacheDir, option.CacheSizeMB) - util.OnInterrupt(func() { + grace.OnInterrupt(func() { wfs.chunkCache.Shutdown() }) } if wfs.option.AsyncMetaDataCaching { wfs.metaCache = meta_cache.NewMetaCache(path.Join(option.CacheDir, "meta")) startTime := time.Now() - if err := meta_cache.InitMetaCache(wfs.metaCache, wfs, wfs.option.FilerMountRootPath); err != nil{ + if err := meta_cache.InitMetaCache(wfs.metaCache, wfs, wfs.option.FilerMountRootPath); err != nil { glog.V(0).Infof("failed to init meta cache: %v", err) } else { go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) - util.OnInterrupt(func() { + grace.OnInterrupt(func() { wfs.metaCache.Shutdown() }) } diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go index 596c91a58..956684d46 100644 --- a/weed/server/filer_server.go +++ b/weed/server/filer_server.go @@ -8,6 +8,7 @@ import ( "sync" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "google.golang.org/grpc" "github.com/chrislusf/seaweedfs/weed/operation" @@ -111,7 +112,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption) fs.filer.LoadBuckets() - util.OnInterrupt(func() { + grace.OnInterrupt(func() { fs.filer.Shutdown() }) diff --git a/weed/server/webdav_server.go b/weed/server/webdav_server.go index 445cc7b4d..11b89677f 100644 --- a/weed/server/webdav_server.go +++ b/weed/server/webdav_server.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/chrislusf/seaweedfs/weed/util/grace" "golang.org/x/net/webdav" "google.golang.org/grpc" @@ -100,7 +101,7 @@ type WebDavFile struct { func NewWebDavFileSystem(option *WebDavOption) (webdav.FileSystem, error) { chunkCache := chunk_cache.NewChunkCache(256, option.CacheDir, option.CacheSizeMB) - util.OnInterrupt(func() { + grace.OnInterrupt(func() { chunkCache.Shutdown() }) return &WebDavFileSystem{ diff --git a/weed/util/pprof.go b/weed/util/grace/pprof.go index a2621ceee..14686bfc8 100644 --- a/weed/util/pprof.go +++ b/weed/util/grace/pprof.go @@ -1,4 +1,4 @@ -package util +package grace import ( "os" diff --git a/weed/util/signal_handling.go b/weed/util/grace/signal_handling.go index 99447e8be..7cca46764 100644 --- a/weed/util/signal_handling.go +++ b/weed/util/grace/signal_handling.go @@ -1,6 +1,6 @@ // +build !plan9 -package util +package grace import ( "os" diff --git a/weed/util/signal_handling_notsupported.go b/weed/util/grace/signal_handling_notsupported.go index c389cfb7e..5335915a1 100644 --- a/weed/util/signal_handling_notsupported.go +++ b/weed/util/grace/signal_handling_notsupported.go @@ -1,6 +1,6 @@ // +build plan9 -package util +package grace func OnInterrupt(fn func()) { } |
