2010-04-12 77 views
4

我正在使用Rails 2.3.5 Dreamhost服務器上工作。最快的方式與乘客部署rails應用程序

每次我對網站進行更改時,我都必須先進入網站,刪除所有文件,上傳包含網站所有新文件的zip文件,解壓縮該文件,遷移數據庫並繼續。

東西告訴我有一種更快的方式來部署rails應用程序。我使用Mac Time Machine來跟蹤我的應用程序的不同版本。我知道git跟蹤文件,但我真的不知道如何使用它來部署我的應用程序,因爲乘客會爲我處理所有魔術。

什麼是更快的方式來部署我的應用程序(並避免與我的方法相關的停機時間,當我刪除服務器上的所有文件)?

謝謝!

回答

1

,先去自己Capistrano的助手:http://github.com/westarete/capistrano-helpers

下面是我自己的網站簡化,標註的部署文件。

require 'capistrano-helpers/branch'  # prompts for branch 
require 'capistrano-helpers/passenger' # Support for Apache passenger 
require 'capistrano-helpers/version' # Record the version number after deploying 
require 'capistrano-helpers/privates' # handle sensitive files 
require 'capistrano-helpers/shared' 

set :application, "site" 
set :repository, "file://." 

set :scm, "git" 
set :branch, "rails3" 
set :deploy_via, :copy 

set :copy_exclude, [ ".git", "assets", "test", "Capfile", "vishvish.tmproj", "bin" ] 

set :deploy_to, "/blah/blah.com/#{application}" 

set :user, "blah" 
set :domain, "blah.com" 

#Things you want symlinked afterwards, not in version control. 
set :privates, %w{ 
    config/database.yml 
} 

#Things you want shared across deployments, not uploaded every time. 
set :shared, %w{ 
    uploads 
} 

role :app, domain 
role :web, domain 
role :db, domain, :primary => true 

namespace :deploy do 
    desc "Restarting mod_rails with restart.txt" 
    task :restart, :roles => :app, :except => { :no_release => true } do 
    run "touch #{current_path}/tmp/restart.txt" 
    end 

    [:start, :stop].each do |t| 
    desc "#{t} task is a no-op with mod_rails" 
    task t, :roles => :app do ; end 
    end 
end 
1

你一定需要git和capistrano。

我的部署過程:

git commit 
git push 
cap deploy 

Git是非常直接的。 github.com上有很多資源和方法。 如果你不使用源代碼控制你絕對必須解決這個問題......