LaunchDaemons和环境变量 [英] LaunchDaemons and Environment Variables

查看:480
本文介绍了LaunchDaemons和环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在注意到,我的MacPorts安装的Apache2实例在启动时还没有启动( MacPorts Apache2在启动时停止启动)。 LaunchDaemon加载。今天我碰到了一个可能指向答案的日志文件中的东西,但是我找不到任何确认。



我使用环境变量在我的 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆