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

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

我正在阅读的手册页systemctl reload并发现了关于的这句话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

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

我也发现了reload-or-restart

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

systemd 如何知道该设备是否支持重新加载?

答案1

以下是手册页中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.

(要知道那是正确的手册页,唯一的办法systemd.service就是在 Google 上搜索ExecReload,这是我在挖掘 Systemd 的源代码后猜到的一个字符串。)

相关内容