我正在尝试使用 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 进行 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">
<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>
答案1
我最终通过以下配置解决了这个问题。
<?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>