systemd 如何要求单元重新加载配置?

425*_*esp 5 systemd systemctl

我正在阅读有关的联机帮助页systemctl reload,发现这句话是关于reload.

reload PATTERN...
    Asks all units listed on the command line to reload their
    configuration.
Run Code Online (Sandbox Code Playgroud)

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

systemd 是如何做到的?systemd 使用什么 API 来要求单元重新加载其配置?

我也发现了reload-or-restart

 reload-or-restart PATTERN...
     Reload one or more units if they support it. If not, restart them
     instead.
Run Code Online (Sandbox Code Playgroud)

systemd 如何知道单元是否支持重新加载?

Thr*_*unt 8

以下是手册页systemd.service关于重新加载的内容:

       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.

Run Code Online (Sandbox Code Playgroud)

(知道这systemd.service是要查看的正确手册页的唯一方法是 Google for ExecReload,这是我在挖掘 Systemd 的源代码后猜测的字符串。)