14

I was reading the manpage for systemctl reload and found this sentence about reload.

reload PATTERN...
    Asks all units listed on the command line to reload their
    configuration.

http://man7.org/linux/man-pages/man1/systemctl.1.html

How does systemd do that? What API does systemd use to ask a unit to reload its configuration?

I also found reload-or-restart.

 reload-or-restart PATTERN...
     Reload one or more units if they support it. If not, restart them
     instead.

How does systemd know if the unit supports reload?

0

1 Answer 1

19

Here's what the man page systemd.service says about reloading:

       ExecReload=
           Commands to execute to trigger a configuration reload in the 
           service. This argument takes multiple command lines, following
           the same scheme as described for ExecStart= above. Use of
           this setting is optional. Specifier and environment variable
           substitution is supported here following the same scheme as
           for ExecStart=.

           One additional, special environment variable is set: if known,
           $MAINPID is set to the main process of the daemon, and may
           be used for command lines like the following:

               /bin/kill -HUP $MAINPID

           Note however that reloading a daemon by sending a signal
           (as with the example line above) is usually not a good
           choice, because this is an asynchronous operation and hence
           not suitable to order reloads of multiple services against
           each other. It is strongly recommended to set ExecReload=
           to a command that not only triggers a configuration reload
           of the daemon, but also synchronously waits for it to complete.

(The only way to know that systemd.service is the correct man page to look in was to Google for ExecReload, a string I guessed after digging through Systemd's source code.)

2
  • There are two man pages, systemd.index(7) and systemd.directives(7), the latter would have been searchable for the string reload.
    – j0057
    Commented Jun 24 at 10:08
  • I would have never, ever guessed to look in those man pages. I ended up resorting to source code analysis, which took hours IIRC. Commented Jul 7 at 22:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .