File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -521,6 +521,13 @@ func (cli *daemonCLI) reloadConfig() {
521521 }
522522 }
523523
524+ // On Linux, we use sd_notify to indicate we're reloading config. We send
525+ // this signal as early as possible to let systemd know we're reloading,
526+ // but must signal "ready" after this completes (even on failure), which
527+ // is done by the reload function defined above.
528+ done := notifyReloading ()
529+ defer done ()
530+
524531 if err := config .Reload (* cli .configFile , cli .flags , reload ); err != nil {
525532 log .G (ctx ).WithError (err ).Error ("Error reloading configuration" )
526533 return
Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ func preNotifyReady() error {
1111func notifyReady () {
1212}
1313
14+ // notifyReloading sends a message to the host when the server got signaled to
15+ // reloading its configuration. It is a no-op on FreeBSD.
16+ func notifyReloading () func () { return func () {} }
17+
1418// notifyStopping sends a message to the host when the server is shutting down
1519func notifyStopping () {
1620}
Original file line number Diff line number Diff line change @@ -58,6 +58,25 @@ func notifyStopping() {
5858 _ , _ = systemdDaemon .SdNotify (false , systemdDaemon .SdNotifyStopping )
5959}
6060
61+ // notifyReloading sends a message to the host when the server got signaled to
62+ // reloading its configuration, see [sd_notify(3)]. The server should be running
63+ // as a systemd unit with "Type=notify" or "Type=notify-reload" (see
64+ // [systemd.service(5)]).
65+ //
66+ // notifyReloading returns a callback that must be called after reloading completes
67+ // (either successfully or unsuccessfully) to send [notifyReady].
68+ //
69+ // [sd_notify(3)]: https://www.freedesktop.org/software/systemd/man/latest/sd_notify.html#RELOADING=1
70+ // [systemd.service(5)]: https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Type=
71+ func notifyReloading () (done func ()) {
72+ sent , _ := systemdDaemon .SdNotify (false , systemdDaemon .SdNotifyReloading + "\n " + systemdDaemon .SdNotifyMonotonicUsec ())
73+ if ! sent {
74+ // Nothing to do if no reloading event was sent.
75+ return func () {}
76+ }
77+ return notifyReady
78+ }
79+
6180func validateCPURealtimeOptions (cfg * config.Config ) error {
6281 if cfg .CPURealtimePeriod == 0 && cfg .CPURealtimeRuntime == 0 {
6382 return nil
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ func preNotifyReady() error {
5656func notifyReady () {
5757}
5858
59+ // notifyReloading sends a message to the host when the server got signaled to
60+ // reloading its configuration. It is a no-op on Windows.
61+ func notifyReloading () func () { return func () {} }
62+
5963// notifyStopping sends a message to the host when the server is shutting down
6064func notifyStopping () {
6165}
You can’t perform that action at this time.
0 commit comments