mirror of
https://github.com/rclone/rclone.git
synced 2026-01-06 02:23:24 +00:00
systemd: prevent unmount rc command from sending a STOPPING=1 sd-notify message
This prevents an `rclone rcd` server from prematurely going into the 'deactivating' state, which was causing systemd to kill it with a SIGABRT after the stop timeout. Fixes #7540
This commit is contained in:
committed by
Nick Craig-Wood
parent
4824837eed
commit
14629c66f9
@@ -18,11 +18,11 @@ import (
|
||||
"github.com/rclone/rclone/fs/config/flags"
|
||||
"github.com/rclone/rclone/lib/atexit"
|
||||
"github.com/rclone/rclone/lib/daemonize"
|
||||
"github.com/rclone/rclone/lib/systemd"
|
||||
"github.com/rclone/rclone/vfs"
|
||||
"github.com/rclone/rclone/vfs/vfscommon"
|
||||
"github.com/rclone/rclone/vfs/vfsflags"
|
||||
|
||||
"github.com/coreos/go-systemd/v22/daemon"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
)
|
||||
@@ -307,6 +307,7 @@ func NewMountCommand(commandName string, hidden bool, mount MountFn) *cobra.Comm
|
||||
// Wait for foreground mount, if any...
|
||||
if mountDaemon == nil {
|
||||
if err == nil {
|
||||
defer systemd.Notify()()
|
||||
err = mnt.Wait()
|
||||
}
|
||||
if err != nil {
|
||||
@@ -385,7 +386,6 @@ func (m *MountPoint) Wait() error {
|
||||
var finaliseOnce sync.Once
|
||||
finalise := func() {
|
||||
finaliseOnce.Do(func() {
|
||||
_, _ = daemon.SdNotify(false, daemon.SdNotifyStopping)
|
||||
// Unmount only if directory was mounted by rclone, e.g. don't unmount autofs hooks.
|
||||
if err := CheckMountReady(m.MountPoint); err != nil {
|
||||
fs.Debugf(m.MountPoint, "Unmounted externally. Just exit now.")
|
||||
@@ -401,11 +401,6 @@ func (m *MountPoint) Wait() error {
|
||||
fnHandle := atexit.Register(finalise)
|
||||
defer atexit.Unregister(fnHandle)
|
||||
|
||||
// Notify systemd
|
||||
if _, err := daemon.SdNotify(false, daemon.SdNotifyReady); err != nil {
|
||||
return fmt.Errorf("failed to notify systemd: %w", err)
|
||||
}
|
||||
|
||||
// Reload VFS cache on SIGHUP
|
||||
sigHup := make(chan os.Signal, 1)
|
||||
NotifyOnSigHup(sigHup)
|
||||
|
||||
Reference in New Issue
Block a user