Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

Commit c453acb

Browse files
committed
catch also SIGTERM, from systemd
1 parent 94dfaaa commit c453acb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121
"os/signal"
2222
"path/filepath"
23+
"syscall"
2324

2425
"google.golang.org/grpc"
2526

@@ -72,7 +73,6 @@ func main() {
7273

7374
// Configure filesystem and snapshotter
7475
fs, err := cvmfs.NewFilesystem(ctx, filepath.Join(*rootDir, "cvmfs"), config)
75-
defer fs.(*cvmfs.Filesystem).UnmountAll(ctx)
7676
if err != nil {
7777
log.G(ctx).WithError(err).Fatalf("failed to configure filesystem")
7878
}
@@ -121,12 +121,13 @@ func main() {
121121
log.G(ctx).WithError(err).Fatalf("error on serving via socket %q", *address)
122122
}
123123
}()
124-
waitForSIGINT()
124+
waitForSignal(fs.(*cvmfs.Filesystem))
125125
log.G(ctx).Info("Got SIGINT")
126126
}
127127

128-
func waitForSIGINT() {
128+
func waitForSignal(fs *cvmfs.Filesystem) {
129129
c := make(chan os.Signal, 1)
130-
signal.Notify(c, os.Interrupt)
130+
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
131131
<-c
132+
fs.UnmountAll(context.TODO())
132133
}

0 commit comments

Comments
 (0)