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

launchd:macOS上控制服务的bootstrap/bootout语义混乱,macos,service,launchd,Macos,Service,Launchd,我已经阅读了有关launchd的以下手册页面:launchctl、launchd和launchd.plist 但是,在这些手册页面中,没有真正说明launchctl boostrap和launchctl bootout(sub)命令的实际功能(见下文)。是从他们的名字推断出来的吗 此外,我在手册页中找不到关于服务(代理/守护进程)运行的用户/组的信息。但是,launchd.plist提到了UserName/GroupName,用于控制系统域的用户/组。那么,在/Library/LaunchAge

我已经阅读了有关launchd的以下手册页面:
launchctl
launchd
launchd.plist

但是,在这些手册页面中,没有真正说明
launchctl boostrap
launchctl bootout
(sub)命令的实际功能(见下文)。是从他们的名字推断出来的吗

此外,我在手册页中找不到关于服务(代理/守护进程)运行的用户/组的信息。但是,
launchd.plist
提到了
UserName
/
GroupName
,用于控制系统域的用户/组。那么,在
/Library/LaunchAgents
~/Library/LaunchAgents
中,每个用户的服务是作为什么运行的呢

最后,我希望我需要
bootstrap
/
加载
我的
守护进程的.plist,但在将.plist放入
/Library/LaunchAgents
/Library/LaunchDaemons
后,它会在系统启动时自动加载(运行)。实际上,
RunAtLoad=true
,但是如果服务仍然运行,
引导的目的是什么

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.

bootstrap
bootout
可用于加载和卸载服务,无需重新启动或登录或注销。如果您需要临时停止服务以执行某些任务,然后在不需要重新启动系统的情况下重新启动服务,则这些功能非常有用

/Library/launchdaemon
默认情况下以root用户身份运行。您可以使用
UserName
GroupName
键来控制守护进程的配置

/Library/LaunchAgents
作为当前登录的用户运行(这些代理针对每个用户运行)

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

进一步阅读:

  • manlaunchd.plist
  • 警告:已过时,但对于launchd的一般工作原理,这仍然是一个有用的基本教程。不包含有关引导/引导输出的信息。使用现已弃用并标记为“遗留”的命令

通过加载,只有指定RunOnLoad的服务将立即运行,对吗?@Shuzheng我在回答中为您添加了一些参考资料。当您使用
RunOnLoad
问题时:它不仅仅依赖于
RunOnLoad
,当您引导时,它会立即加载.plist并可以运行几个“何时运行”类型键,例如“StartInterval”。谢谢,我已经阅读了《守护程序和服务编程指南》。但是,我找不到有关
launchctl
bootstrap
bootout
(sub)命令的任何文档,可以吗?只有
manlaunchctl
定义了
bootstrap
如“this command bootstraps…”,这不是很有帮助。@Shuzheng不,除了
manlaunchctl
,我没有发现任何东西,但是,我认为
bootstrap
相当于系统在引导时读取.plist文件的特殊目录时所做的操作。
boot*
命令取代了
*load
命令,其功能与之类似,只是它们在声明服务时更加详细,可能是为了避免在加载和卸载服务时出现歧义。你还需要知道什么?不需要了,谢谢。我希望他们写过,“
bootstrap
load
的新等价物”——这本可以让我免于一些困惑。此外,加载与运行不同。加载只是指加载plist文件,然后等待某个键触发服务运行(然后将实际的服务二进制文件加载到内存中)。对的