“ systemctl daemon-reload”有什么作用?


46

我的服务突然停止了。我试图重新启动该服务,但失败了,并要求运行“ systemctl daemon-reload”。

它到底是做什么的?什么是“守护程序重载”?

Answers:


47

man systemctl说:

   daemon-reload
       Reload systemd manager configuration. This will rerun all generators (see systemd.generator(7)), reload
       all unit files, and recreate the entire dependency tree. While the daemon is being reloaded, all sockets
       systemd listens on behalf of user configuration will stay accessible.

       This command should not be confused with the reload command.

因此,本质上,这是一次“软”重新加载;从文件系统中获取更改的配置并重新生成依赖树

因此,systemd.generator声明:

生成器是小型二进制文件,位于/ usr / lib / systemd / user-generators /和上面列出的其他目录中。systemd(1)将在启动时和配置重新加载时(在加载单元文件之前)很早地执行这些二进制文件。生成器可以动态生成单位文件或创建到单位文件的符号链接以添加其他依赖关系,从而扩展或覆盖现有定义。它们的主要目的是将不是本机单元文件的配置文件动态转换为本机单元文件。

   Generators are loaded from a set of paths determined during compilation, listed above. System and user
   generators are loaded from directories with names ending in system-generators/ and user-generators/,
   respectively. Generators found in directories listed earlier override the ones with the same name in
   directories lower in the list. A symlink to /dev/null or an empty file can be used to mask a generator,
   thereby preventing it from running. Please note that the order of the two directories with the highest
   priority is reversed with respect to the unit load path and generators in /run overwrite those in /etc.

   After installing new generators or updating the configuration, systemctl daemon-reload may be executed. This
   will delete the previous configuration created by generators, re-run all generators, and cause systemd to
   reload units from disk. See systemctl(1) for more information.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.