[英]Starting git-daemon on OS X using launchd
我正在嘗試使用我的OS X桌面設置內部git服務器(主要作為測試用例)。 當涉及SSH密鑰時,一切正常,但我目前正在嘗試使用git-daemon進行只讀克隆。 如果我在終端中啟動git-daemon:
sudo -u git git-daemon --basepath=/Users/git/repos/ --export-all
然后一切正常,例如
git clone git://localhost/My_Project.git
但是當我嘗試使用launchd進行設置時,它會拒絕所有請求。 我正在使用這個plist文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>git</string>
<key>UserName</key>
<string>git</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/path/to/git-daemon</string>
<string>--base-path=/Users/git/repos/</string>
<string>--export-all</string>
</array>
</dict>
</plist>
如果我嘗試克隆My_Project,則會收到以下錯誤:
Cloning into My_Project...
fatal: The remote end hung up unexpectedly
令人沮喪的是,我相信這曾經有用,所以問題可能與我的plist文件或者launchd的使用關系不大,而且更多的是做任何可能已經改變的網絡設置。 任何建議將不勝感激。
抱歉,如果這更像是一個系統管理員問題,但我認為開發人員可能會有一些經驗。
更新:如果存在repo,控制台將報告以下錯誤:
git[431]
error: cannot run upload-pack: No such file or directory
問題是git-daemon無法在從launchd進程繼承的PATH中的任何目錄中找到git可執行文件。 它從shell啟動時有效,因為從shell繼承的PATH包含相應的目錄。
通常,Git命令是通過main git命令調用的(例如git commit
,而不是(不再) git-commit
)。 除此之外,main git命令將內置的“exec path”添加到“子命令”將繼承的PATH環境變量中。
你的launchd配置直接調用一個“內部”程序 - git-daemon - 而不是讓普通的頂級程序調用它(在擴展它將繼承的PATH之后)。
使用以下ProgramArguments :
<array>
<string>/path/to/git</string>
<string>daemon</string>
<string>--base-path=/Users/git/repos/</string>
<string>--export-all</string>
</array>
其中/path/to/git
是正常shell會話中which git
報告的內容。
你沒告訴它要跑。 嘗試取出OnDemand
並添加:
<key>KeepAlive</key>
<true/>
<key>RunAtLoad</key>
<true/>
或者,您可以使用inetdCompatibility
(另請參閱: Sockets
)和git-daemon
的--inetd
標志,以使進程僅在連接時啟動。 這對你來說可能是一個更好的配置,盡管可能需要更多的工作才能開始。
launchd.plist(5)手冊頁包含所有詳細信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.