From 99dd748fec0ab38919e7ffb209b1045612516f2f Mon Sep 17 00:00:00 2001 From: Shyim Date: Mon, 10 Apr 2023 16:22:54 +0200 Subject: [PATCH] serve restic: trigger systemd notify Allow to use Type=notify together with serving restic api --- cmd/serve/restic/restic.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cmd/serve/restic/restic.go b/cmd/serve/restic/restic.go index db6427dad..5ad1b1675 100644 --- a/cmd/serve/restic/restic.go +++ b/cmd/serve/restic/restic.go @@ -13,6 +13,8 @@ import ( "strings" "time" + sysdnotify "github.com/iguanesolutions/go-systemd/v5/notify" + "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" "github.com/rclone/rclone/cmd" @@ -177,7 +179,17 @@ with a path of ` + "`//`" + `. return nil } fs.Logf(s.f, "Serving restic REST API on %s", s.URLs()) + + if err := sysdnotify.Ready(); err != nil { + fs.Logf(s.f, "failed to notify ready to systemd: %v", err) + } + s.Wait() + + if err := sysdnotify.Stopping(); err != nil { + fs.Logf(s.f, "failed to notify stopping to systemd: %v", err) + } + return nil }) },