开发者

Fastest way to deploy rails apps with Passenger

I am working on a Dreamhost server with Rails 2.3.5.

Every time I make c开发者_高级运维hanges to a site, I have to ssh into the site, remove all the files, upload a zip file containing all the new files for the site, unzip that file, migrate the database, and go.

Something tells me there's a faster way to deploy rails apps. I am using mac Time Machine to keep track of different versions of my applications. I know git tracks files, but I don't really know how to work with it to deploy my applications, since passenger takes care of all the magic for me.

What would be a faster way to deploy my applications (and avoid the downtime associated with my method when I delete all files on the server)?

Thanks!


Take a look at Capistrano.


And go get yourself Capistrano helpers: http://github.com/westarete/capistrano-helpers

Here's a simplified, annotated Deploy file for my own site.

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


You definitely need git and capistrano.

My deployment process:

git commit
git push
cap deploy

Git is pretty straight forward. There are a ton of resources and how-tos on github.com. If you aren't using source control you absolutely MUST fix that ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜