2014-09-01 115 views
0

我很少部署Rails應用程序,因此當我做這件事時,我總是會與Capistrano進行一次正面比賽。在這裏,我在Github上有一個回購。我使用Capistrano的3.2.1和我deploy.rb相關(即非樣板)的部分是:Capistrano 3部署初始化

lock '3.2.1' 

set :application, 'my_app' 
set :scm, :git 
set :repository, "[email protected]:my_github_user/my_app.git" 


set :user, 'deploy' 
set :deploy_to, "/home/deploy/rails_apps/my_app" 

config/deploy/production.rb我有這樣的:

role :app, %w{[email protected]_domain.com} 
role :web, %w{[email protected]_domain.com} 
role :db, %w{[email protected]_domain.com} 

我先掛了上出現以下錯誤:

DEBUG[03378c05] Running /usr/bin/env git ls-remote -h on my_domain.com 
DEBUG[03378c05] Command: (GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/my_app/git-ssh.sh /usr/bin/env git ls-remote -h ) 
DEBUG[03378c05]  usage: git ls-remote [--heads] [--tags] [-u <exec> | --upload-pack <exec>] <repository> <refs>... 
DEBUG[03378c05] Finished in 0.165 seconds with exit status 129 (failed). 

還要注意,我重複字符串,如my_app。我曾經是能夠做到:

set :repository, "[email protected]:my_github_user/#{application}.git" 

,但現在我得到的屬性或方法application沒有發現錯誤。

我知道我錯過了一個或多個步驟。我簡直無法弄清楚這些步驟是什麼。

任何想法?

回答

0

使用set :repository, "[email protected]:my_github_user/#{fetch(:application)}.git"

+0

解決插值問題,謝謝。 (退一步語法醋,國際海事組織),但不是在git ls-remote失敗。任何線索呢? – 2014-09-01 20:49:39

0

好的,我明白了。告訴你我總是與Capistrano碰頭!

:repository變量更改爲:repo_url(d'oh)。

使用fetch如上所述工作。

您還需要提到here的行添加到您重新啓動腳本:

task :restart do 
    on roles(:app), in: :sequence, wait: 5 do 
    # Your restart mechanism here, for calicowebdev: 

    execute :mkdir, '-p', "#{ release_path }/tmp" 

mkdir的部分是你需要添加什麼。