mirror of
https://github.com/caddyserver/caddy.git
synced 2026-01-17 01:30:34 +00:00
cmd: Implement sd_notify() to notify systemd about readiness (#3963)
Issue: #3786 Based on Gaurav Dhameeja's work in #3908.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user