2012-08-28 41 views
1

我創建了一個plist中,看起來像這樣:我的守護進程是從註銷/登錄的launchd未註冊

<?xml version=\"1.0\" encoding=\"UTF-8\"?> 
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd\"> 
<!-- My version "1.2.3" --> 
<plist version=\"1.0\"> 
<dict> 
<key>Disabled</key> 
<false/> 
<key>Label</key> 
<string>MyPlistName</string> 
<key>ProgramArguments</key> 
<array> 
<string>MyDaemonBinPath</string> 
<string>-log</string> 
<string>MyLogLevel</string> 
<string>-launchd</string> 
</array> 
<key>Sockets</key> 
<dict> 
<key>Listeners</key> 
<dict> 
<key>SockFamily</key> 
<string>Unix</string> 
<key>SockPathMode</key> 
<integer>438</integer> 
<key>SockPathName</key> 
<string>MySocketName</string> 
</dict> 
</dict> 
<key>StandardErrorPath</key> 
<string>MySTDERRLogPath</string> 
<key>WaitForDebugger</key> 
<false/> 
<key>inetdCompatibility</key> 
<dict> 
<key>Wait</key> 
<false/> 
</dict> 
</dict> 
</plist> 

我把它放在/ Library/LaunchDaemons

我然後運行命令:

/bin/launchctl unload /Library/LaunchDaemons/MyPlistName.plist 
/bin/launchctl load /Library/LaunchDaemons/MyPlistName.plist 

我的守護進程不會啓動,當我連接到plist中指定的插座,當我鍵入:

launchctl list 

的守護程序註冊,但是當我註銷並重新登錄,並再次要求列表,它不再登記,我不能連接到插座

啓動我的守護進程有一些特殊權限我需要設置plist或守護進程來讓這個在會話之間持續下去?

回答

0

您是否檢查了您的/var/log/system.log錯誤? /Library/LaunchDaemons/中的常規plist在啓動時以root用戶身份運行。您可能想檢查sudo launchctl list以查看它們是否運行。如果沒有,您可能需要更改plists的所有權/讀取+寫入屬性以匹配根目錄。最後,您可以包括以下內容以改進日誌記錄:

<key>StandardErrorPath</key> 
    <string>/logs/launchd_myprogram_stderr.log</string> 
<key>StandardOutPath</key>   
    <string>/logs/launchd_myprogram_stdout.log</string> 
+0

謝謝。我有一段時間沒有看過這個問題,但是當我這樣做時,我會試試看。 – cppguy

+0

@cppguy做了這個訣竅嗎?如果是這樣,我們可以「關閉」或評價這個問答帖子嗎? – gdh