mirror of
https://github.com/rclone/rclone.git
synced 2024-11-25 09:41:44 +08:00
rcd: Added systemd notification during the 'rclone rcd' command call. This also fixes #5073.
Signed-off-by: Naveen Honest Raj <naveendurai19@gmail.com>
This commit is contained in:
parent
18cd2064ec
commit
02a5d350f9
|
@ -3,10 +3,13 @@ package rcd
|
|||
import (
|
||||
"context"
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
sysdnotify "github.com/iguanesolutions/go-systemd/v5/notify"
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/fs/rc/rcflags"
|
||||
"github.com/rclone/rclone/fs/rc/rcserver"
|
||||
"github.com/rclone/rclone/lib/atexit"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
|
@ -48,6 +51,22 @@ See the [rc documentation](/rc/) for more info on the rc flags.
|
|||
log.Fatal("rc server not configured")
|
||||
}
|
||||
|
||||
// Notify stopping on exit
|
||||
var finaliseOnce sync.Once
|
||||
finalise := func() {
|
||||
finaliseOnce.Do(func() {
|
||||
_ = sysdnotify.Stopping()
|
||||
})
|
||||
}
|
||||
fnHandle := atexit.Register(finalise)
|
||||
defer atexit.Unregister(fnHandle)
|
||||
|
||||
// Notify ready to systemd
|
||||
if err := sysdnotify.Ready(); err != nil {
|
||||
log.Fatalf("failed to notify ready to systemd: %v", err)
|
||||
}
|
||||
|
||||
s.Wait()
|
||||
finalise()
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user