2009-07-20 27 views
1

我正在嘗試將Rails應用程序部署到運行Passenger的CentOS服務器。 SVN存儲庫和MySQL數據庫分別託管在不同的機器上。 (換句話說,有一個總參與三個獨立的主機。)如何爲Capistrano指定單獨的應用程序和數據庫服務器?

這裏是我的deploy.rb文件(從Passenger docs拍攝):

set :application, 'myapp' 
set :repository, 'svn+ssh://[email protected]_host.com/var/svn/myapp/trunk' 

# Changed this to true because I do in fact use sudo. 
set :use_sudo, true 

set :deploy_to, "/opt/deployed_rails_apps/#{application}" 

role :app, '[email protected]_host.com' 
role :web, '[email protected]_host.com' 

# Originally this had a "primary => true" option, but cap deploy:setup failed 
# when that option was present. 
role :db, '[email protected]_host.com'  

namespace :deploy do 
    task :start, :roles => :app do 
    run "touch #{current_release}/tmp/restart.txt" 
    end 

    task :stop, :roles => :app do 
    # Do nothing. 
    end 

    desc "Restart Application" 
    task :restart, :roles => :app do 
    run "touch #{current_release}/tmp/restart.txt" 
    end 
end 

cap deploy:setup似乎成功。至少沒有錯誤。但cap deploy失敗。有很多輸出,但結果似乎是Capistrano試圖將我的應用部署到我爲:db指定的「角色」 - 嘗試將應用部署到主機的DB

servers: ["app_host.com", "db_host.com"] 

...

** [db_host :: out] Permission denied, please try again. 
** [db_host :: out] [email protected]_host.com's password: 

...

failed: "sh -c 'svn checkout -q -r184 svn+ssh://[email protected]_host.com/var/svn/myapp/trunk /opt/deployed_rails_apps/myapp/releases/20090720190553 && (echo 184 > /opt/deployed_rails_apps/myapp/releases/20090720190553/REVISION)'" on [email protected]_host.com 

回答

4

如果您不需要在數據庫框中輸入您的Rails代碼,這是一個簡單的辦法 - 沒有定義角色:db

cap deploy默認將代碼放在您定義的所有角色的所有框中。

+0

謝謝。那麼爲什麼包含在這麼多例子中的「db」角色呢?在什麼情況下,我想要在數據庫框中添加應用程序代碼? – Ethan 2009-07-20 20:08:10

相關問題