2010-02-19 178 views
18

我想爲我的應用做'deploy:cold'。 git repo是我的部署服務器的本地 (即,我只有一臺服務器,並且我不會在github上託管我的代碼)。Capistrano + Git:存儲庫本地到生產服務器

下面是全文(更換我的應用程序名稱以 「MYAPP」 隱私)

* executing `deploy:cold' 
    * executing `deploy:update' 
** transaction: start 
    * executing `deploy:update_code' 
    executing locally: "git ls-remote /home/mrichman/git/myapp.git master" 
fatal: '/home/mrichman/git/myapp.git' does not appear to be a git repository 
fatal: The remote end hung up unexpectedly 
*** [deploy:update_code] rolling back 
    * executing "rm -rf /var/www/myapp.com/releases/20100218203108; true" 
    servers: ["myapp.com"] 
Password: 
    [myapp.com] executing command 
    command finished 
Command git ls-remote /home/mrichman/git/myapp.git master returned status code 32768 

這裏是我的deploy.rb:http://pastie.org/831424

我也曾嘗試

set :repository, "[email protected]:/home/mrichman/git/myapp.git" 

但那給了我

ssh: connect to host localhost port 22: Connection refused 

任何想法表示讚賞。

回答

16

剛剛遇到同樣的問題。關鍵是不使用deploy_via複製,而是設置:local_repository

這應該設置爲您用來從開發計算機/筆記本電腦訪問存儲庫的URL。

所以該礦擁有

set :repository, "file:///srv/git/myapp.git" 
set :local_repository, "nameOfHostFromSSHConfig:/srv/git/myapp.git" 

似乎已經奏效。請記住,然後再刪除deploy_via複製行。

+0

我現在有以下,這也將失敗: 組:倉庫, 「文件:///var/git/myapp.git」 集:local_repository, 「本地主機:/var/git/myapp.git」 本地執行:「git ls-remote localhost:/var/git/hireexchange.git master」 ssh:連接到主機localhost端口22:連接被拒絕 – 2010-02-28 14:30:52

+1

你在同一個盒子上開發嗎?如果你是我想象:local_repository,「file://var/git/myapp.git」將工作。 localhost應該替換爲您從假定的遠程工作站連接到的任何主機名。 此外,我發現如果你有子模塊,你會遇到更多的問題做這樣的部署,因爲模塊被設置爲指向一個遠程URL。 非常討厭,但可以在您部署的用戶下的服務器上使用.ssh/config來解決。 – pmarsh 2010-02-28 14:52:46

+1

嗨,大家好。如果它有什麼區別,我的本地和遠程機器上的git需要不同的路徑,因此我需要設置:git_local/path/to/remote/git和set:git/usr/bin/git(注意這些不需要ssh開始)。 – btelles 2010-05-11 21:14:04

1

身份登錄要部署到該網站的用戶,並嘗試這個,看看你的用戶有權限訪問該目錄:

LS -LA /home/mrichman/git/myapp.git

如果您獲得Permission denied錯誤,那麼您必須確保在存儲庫的封閉目錄上設置權限,以允許部署腳本訪問這些文件。

+0

我已經驗證了我的部署用戶必須/home/mrichman/git/myapp.git完全讀取訪問。感謝您的評論。 – 2010-02-19 12:47:53

+0

嘗試登錄到部署用戶帳戶並手動輸入失敗的命令:「git ls-remote /home/mrichman/git/myapp.git master」,它可能會給你同樣的錯誤,如果有,請登錄作爲mrichman用戶並以該用戶身份試用。如果這仍然給出了一個錯誤,我敢打賭,那麼你會想進入「/ home/mrichman/git/myapp」。git「目錄並輸入」git status「,如果失敗,你需要檢查該目錄的內容是否確實包含git存儲庫。 – rwl4 2010-02-19 22:20:40

+0

當我將git ls-remote作爲我的部署用戶或我自己的用戶我看起來很成功:'aa30ffc814fffd96b168ffec7224aeb9fe9df161 \t refs/heads/master'。我相信'git status'只適用於工作樹,而不是實際的版本庫 作爲一個實驗,我將我的回購推到Codaset, 'cap deploy'正常工作,我可以(也許應該)繼續這樣做,因爲把SCM放在他們的web服務器上是不安全的:) – 2010-02-20 11:46:15

0

請確保您已寫入正確的git回購關懷區分大小寫寫作! (我面臨同樣的問題,它剛剛解決)

0

我的問題實際上與已知的主機問題有關。我所要做的只是確保遠程git服務器位於我已知的主機中(第一次嘗試SSH進入時會提示你自己添加它),並且它像一個魅力一樣工作。

0

如果設置了local_repository,則Capistrano將使用部署服務器中的respository值和來自開發服務器的值local_respositoryOr something like that.

我的配置工作就像這樣:

set :repository, "/home/#{user}/path/to/repo.git" 
set :local_repository, "myserver.com:path/to/repo.git" 
相關問題