launchd:混淆 bootstrap/bootout 在 macOS 上控制服务的语义

launchd: Confusion on the sematics of bootstrap/bootout for controlling services on macOS

我在 launchd 上阅读了以下手册页:launchctllaunchdlaunchd.plist

然而,这些手册页中并没有真正说明 launchctl boostraplaunchctl bootout(子)命令的实际作用(见下文)。是从他们的名字推断出来的吗?

此外,我无法在手册页中找到有关 user/group 服务 (agent/daemon) 运行 是什么的信息。但是,launchd.plist 提到 UserName/GroupName 用于控制系统域的 user/group。那么,/Library/LaunchAgents~/Library/LaunchAgents 运行 中的每用户服务是什么用户?

最后,我希望我需要 bootstrap/load 我的 daemon 的 .plist,但是在将 .plist 放入 /Library/LaunchAgents/Library/LaunchDaemons,它在系统启动时自动加载 (运行)。的确,RunAtLoad=true,但是 bootstrap 的目的是什么,如果服务 运行 呢?

man launchctl:

 bootstrap | bootout domain-target [service-path service-path2 ...] | service-target
          Bootstraps or removes domains and services. When service arguments are present, bootstraps and correspondingly removes their definitions into the domain.  Services may be specified as a series of
          paths or a service identifier.  Paths may point to XPC service bundles, launchd.plist(5) s, or a directories containing a collection of either. If there were one or more errors while bootstrapping or
          removing a collection of services, the problematic paths will be printed with the errors that occurred.

          If no paths or service target are specified, these commands can either bootstrap or remove a domain specified as a domain target. Some domains will implicitly bootstrap pre-defined paths as part of
          their creation.

bootstrapbootout 可用于加载和卸载服务 而无需 重新启动或登录和注销。如果您需要暂时停止服务以执行某些任务然后在不需要重新启动系统的情况下再次启动它,它们会很有用。

/Library/LaunchDaemons 运行 默认为 root。您可以使用 UserNameGroupName 键来控制守护进程的配置。

/Library/LaunchAgents 运行 作为当前登录的用户(这些 运行 适用于每个用户)。

~/Library/LaunchAgents 运行 作为特定用户。

进一步阅读: