LaunchDaemons和环境变量 [英] LaunchDaemons and Environment Variables
问题描述
我使用环境变量在我的 httpd.conf
文件。具体来说, $ {HOME}
变量。在执行LaunchDaemons时,环境变量是否可能(或可能等)环境变量完全加载?我可以将它们添加到 plist
文件中,但我希望有人能够为OS X的启动过程提供一个体面的高级外观,并确认我的想法我看到
谢谢。
a href =http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/BootProcess.html#//apple_ref/doc/uid/20002130 =nofollow noreferrer> this有关MacOSX上的引导过程的页面,其中包含一些信息。基本上, launchd
已启动,并以root身份运行。然后,基于 launchd 启动每个守护进程man5 / launchd.plist.5.htmlrel =nofollow noreferrer> plist
文件。
<关于守护进程中的环境,我没有找到一点显式的信息。但是,在阅读了 launchctl man,我发现一个命令可以打印出
launchd
的环境。所以诀窍是去根
并问: #$> ; sudo su
密码:
#$> whoami
root
#$> launchctl
launchd%export
PATH =/ usr / bin:/ bin:/ usr / sbin:/ sbin;出口路径;
launchd%exit
#$>退出
我推断打印环境是启动后台程序时使用的环境。如果您重复操作而不进行 root
,环境必须与用户的环境相匹配。
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.
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:
#$> sudo su
Password:
#$> whoami
root
#$> launchctl
launchd% export
PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
launchd% exit
#$> 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.
这篇关于LaunchDaemons和环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!