aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/commandfuncs.go
diff options
context:
space:
mode:
authorStefan Tatschner <[email protected]>2021-01-12 22:38:53 +0100
committerGitHub <[email protected]>2021-01-12 14:38:53 -0700
commit59071ea15d2aacb69fcfc088f4996717cd2bfc73 (patch)
tree69a5670ec29233ad2e4e6008cda89acd635c8f43 /cmd/commandfuncs.go
parent14f50d9dfb6c0da0da636829175a37b1864d23cf (diff)
downloadcaddy-59071ea15d2aacb69fcfc088f4996717cd2bfc73.tar.gz
caddy-59071ea15d2aacb69fcfc088f4996717cd2bfc73.zip
cmd: Implement sd_notify() to notify systemd about readiness (#3963)
Issue: #3786 Based on Gaurav Dhameeja's work in #3908.
Diffstat (limited to 'cmd/commandfuncs.go')
-rw-r--r--cmd/commandfuncs.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go
index 25cbe5879..1ee7dd87c 100644
--- a/cmd/commandfuncs.go
+++ b/cmd/commandfuncs.go
@@ -271,6 +271,10 @@ func cmdRun(fl Flags) (int, error) {
}
}
+ if err := NotifyReadiness(); err != nil {
+ caddy.Log().Error("unable to notify readiness to service manager", zap.Error(err))
+ }
+
select {}
}
@@ -291,6 +295,15 @@ func cmdReload(fl Flags) (int, error) {
reloadCmdConfigAdapterFlag := fl.String("adapter")
reloadCmdAddrFlag := fl.String("address")
+ if err := NotifyReloading(); err != nil {
+ caddy.Log().Error("unable to notify reloading to service manager", zap.Error(err))
+ }
+ defer func() {
+ if err := NotifyReadiness(); err != nil {
+ caddy.Log().Error("unable to notify readiness to service manager", zap.Error(err))
+ }
+ }()
+
// get the config in caddy's native format
config, configFile, err := loadConfig(reloadCmdConfigFlag, reloadCmdConfigAdapterFlag)
if err != nil {