LaunchDaemons 和环境变量

发布于 2024-08-20 12:41:35 字数 437 浏览 7 评论 0原文

一段时间以来,我注意到我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单身狗的梦 2024-08-27 12:41:35

我发现 此页面有关 MacOSX 上的启动过程,其中包含一些信息。基本上,launchd 以 root 身份启动并运行。然后,每个守护进程都由基于 plist 文件。

关于守护进程启动时的环境,我没有找到任何明确的信息。但在阅读 launchctl 老兄,我找到了一个可以打印出launchd环境的命令。所以诀窍是进入 root 并询问:

#
gt; sudo su
Password:
#
gt; whoami
root
#
gt; launchctl
launchd% export
PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
launchd% exit
#
gt; exit

我推断打印环境是守护进程启动时使用的环境。如果您在不进入 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 by launchd based on the plist 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 go root and ask:

#
gt; sudo su
Password:
#
gt; whoami
root
#
gt; launchctl
launchd% export
PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
launchd% exit
#
gt; exit

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文