Fixed Ctrl-C handling
This commit is contained in:
@@ -6,6 +6,7 @@ var (
|
||||
ErrFilesystem = errors.New("filesystem")
|
||||
ErrConnectDependencies = errors.New("failed to connect dependencies")
|
||||
ErrFailedToPrepareDirectories = errors.New("failed to prepare directories")
|
||||
ErrFailedToGetWaitGroup = errors.New("failed to get global waitgroup")
|
||||
ErrNoSource = errors.New("source does not exist")
|
||||
ErrFailedToCleanupDestination = errors.New("failed to clean up destination directory")
|
||||
ErrFailedToCreateDestinationDirectory = errors.New("failed to create destination directory")
|
||||
|
||||
@@ -58,9 +58,14 @@ func (f *FS) Start() error {
|
||||
return fmt.Errorf("%w: %w (%w)", ErrFilesystem, ErrFailedToPrepareDirectories, err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg := f.app.GetGlobalWaitGroup()
|
||||
if wg == nil {
|
||||
return fmt.Errorf("%w: %w (%s)", ErrFilesystem, ErrFailedToGetWaitGroup, "got nil waitgroup")
|
||||
}
|
||||
|
||||
wg.Go(func() {
|
||||
f.mount()
|
||||
}()
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ func (f *FS) mount() {
|
||||
}
|
||||
defer server.Unmount()
|
||||
|
||||
select {
|
||||
case <-f.app.Context().Done():
|
||||
return
|
||||
default:
|
||||
server.Wait()
|
||||
}
|
||||
<-f.app.Context().Done()
|
||||
f.app.Logger().Debug("Application context cancelled, unmounting FUSE server...")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user