From e00443a940db81b195575309b9ff9128678de896 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 6 Jun 2021 20:22:42 -0700 Subject: [PATCH] mount: adjust starting order avoid possible nil wfs.Server --- weed/command/mount_std.go | 1 + weed/filesys/wfs.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/weed/command/mount_std.go b/weed/command/mount_std.go index dce2197d6..cdf340067 100644 --- a/weed/command/mount_std.go +++ b/weed/command/mount_std.go @@ -246,6 +246,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool { glog.V(0).Infof("mounted %s%s to %v", *option.filer, mountRoot, dir) server := fs.New(c, nil) seaweedFileSystem.Server = server + seaweedFileSystem.StartBackgroundTasks() err = server.Serve(seaweedFileSystem) // check if the mount process has an error to report diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 178e4e497..0e0050964 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -125,8 +125,6 @@ func NewSeaweedFileSystem(option *Option) *WFS { glog.V(4).Infof("InvalidateEntry %s : %v", filePath, err) } }) - startTime := time.Now() - go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) grace.OnInterrupt(func() { wfs.metaCache.Shutdown() }) @@ -141,6 +139,11 @@ func NewSeaweedFileSystem(option *Option) *WFS { return wfs } +func (wfs *WFS) StartBackgroundTasks() { + startTime := time.Now() + go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) +} + func (wfs *WFS) Root() (fs.Node, error) { return wfs.root, nil }