LaunchDaemons 和环境变量
一段时间以来,我注意到我的 MacPorts 安装的 Apache2 实例在启动时尚未启动 (MacPorts Apache2 停止在启动时启动)。 LaunchDaemon 已加载。今天我在日志文件中发现了一些可能指向答案的内容,但我找不到任何确认。
我在 httpd.conf
文件中使用环境变量。具体来说,是 ${HOME}
变量。当LaunchDaemons执行时,环境变量是否有可能(或可能等)被完全加载?我可以将它们添加到 plist
文件中,但我希望有人能够为我提供对 OS X 启动过程的体面、高级的了解,并确认我所看到的内容。
谢谢。
For a while now, I've been noticing that my MacPorts-installed Apache2 instance hasn't been starting when I start up (MacPorts Apache2 Stopped Launching on Boot). The LaunchDaemon is loaded. Today I bumped into something in a log file that may point to an answer, but I can't find any confirmation.
I use environment variables in my httpd.conf
file. Specifically, the ${HOME}
variable. Is it possible (or probable, etc.) that environmental variables are fully loaded when LaunchDaemons are executed? I can add them to the plist
file, but I'm hoping someone can provide me with a decent, high level look into the boot process of OS X and confirm what I think I'm seeing.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现 此页面有关 MacOSX 上的启动过程,其中包含一些信息。基本上,
launchd
以 root 身份启动并运行。然后,每个守护进程都由基于plist
文件。关于守护进程启动时的环境,我没有找到任何明确的信息。但在阅读 launchctl 老兄,我找到了一个可以打印出
launchd
环境的命令。所以诀窍是进入 root 并询问:我推断打印环境是守护进程启动时使用的环境。如果您在不进入
root
的情况下重复该操作,则环境必须与用户的环境匹配。I found this page about the Boot Process on MacOSX, which contains some information. Basically,
launchd
is started and run as root. Every daemons is then started bylaunchd
based on theplist
file.Regarding the environment during daemon start, I have not find a single bit of explicit information. But after reading the launchctl man, I found a command that can print out the environment of
launchd
. So the trick is to goroot
and ask:I infer that the print environment is the one used when daemons are started. If you repeat the operation without going
root
, the environment must match the user's one.