Git

如何使用 launchd 執行 git daemon(按需,inited 樣式)?

  • September 13, 2013

我正在嘗試使用 launchd 執行 git 守護程序(按需,初始化樣式)。

git clone git clone git://127.0.0.1/testrepo失敗了

Cloning into 'testrepo'...
fatal: unable to connect to 127.0.0.1
127.0.0.1[0: 127.0.0.1]: errno=Connection refused

沒有 onDemand 標誌它可以正常工作。

我正在使用以下 plist 進行啟動。

<?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">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>org.git.daemon</string>
   <key>OnDemand</key>
   <true/>
   <key>ProgramArguments</key>
   <array>
       <string>/usr/local/git/bin//git</string>
       <string>daemon</string>
       <string>--base-path=/apath/path</string>
       <string>--inetd</string>
       <string>--export--all</string>
       <string>--verbose</string>
   </array>
   <key>RunAtLoad</key>
   <false/>
   <key>ServiceDescription</key>
   <string>Git server</string>
   <key>Sockets</key>
   <dict>
       <key>Listeners</key>
       <dict>
           <key>SockFamily</key>
           <string>IPv4</string>
           <key>SockServiceName</key>
           <string>9418</string>
           <key>SockType</key>
           <string>dgram</string>
       </dict>
   </dict>
   <key>UserName</key>
   <string>git</string>
   <key>inetdCompatibility</key>
   <dict>
       <key>Wait</key>
       <false/>
   </dict>
</dict>
</plist>

我終於通過以下配置解決了這個問題。

<?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">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>org.git.daemon</string>
   <key>OnDemand</key>
   <true/>
   <key>ProgramArguments</key>
   <array>
       <string>/usr/local/git/bin/git</string>
       <string>daemon</string>
       <string>--base-path=/Volumes/Development/GitRepos</string>
       <string>--inetd</string>
       <string>--export-all</string>
       <string>--verbose</string>
       <string>--informative-errors</string>
   </array>
   <key>RunAtLoad</key>
   <false/>
   <key>ServiceDescription</key>
   <string>Git server</string>
   <key>Sockets</key>
   <dict>
       <key>Listeners</key>
       <dict>
           <key>SockFamily</key>
           <string>IPv4</string>
           <key>SockServiceName</key>
           <string>9418</string>
           <key>SockType</key>
           <string>stream</string>
       </dict>
   </dict>
   <key>UserName</key>
   <string>git</string>
   <key>inetdCompatibility</key>
   <dict>
       <key>Wait</key>
       <false/>
   </dict>
</dict>
</plist>

引用自:https://serverfault.com/questions/481940