1
mirror of https://github.com/rclone/rclone synced 2024-11-24 01:26:25 +01:00

serve restic: trigger systemd notify

Allow to use Type=notify together with serving restic api
This commit is contained in:
Shyim 2023-04-10 16:22:54 +02:00 committed by GitHub
parent bdfe213c47
commit 99dd748fec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 ` + "`/<username>/`" + `.
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
})
},