mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
mount: use sdnotify to signal systemd the mount is ready
When the NOTIFY_SOCKET environment variable is set notify systemd after the mount is ready.
This commit is contained in:
committed by
Nick Craig-Wood
parent
0bfa29cbcf
commit
d8b3bf014d
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ncw/rclone/vfs"
|
||||
"github.com/ncw/rclone/vfs/vfsflags"
|
||||
"github.com/okzk/sdnotify"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@@ -126,6 +127,10 @@ func Mount(f fs.Fs, mountpoint string) error {
|
||||
sigHup := make(chan os.Signal, 1)
|
||||
signal.Notify(sigHup, syscall.SIGHUP)
|
||||
|
||||
if err := sdnotify.SdNotifyReady(); err != nil && err != sdnotify.SdNotifyNoSocket {
|
||||
return errors.Wrap(err, "failed to notify systemd")
|
||||
}
|
||||
|
||||
waitloop:
|
||||
for {
|
||||
select {
|
||||
@@ -147,6 +152,7 @@ waitloop:
|
||||
}
|
||||
}
|
||||
|
||||
_ = sdnotify.SdNotifyStopping()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to umount FUSE fs")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user