Skip to content

Instantly share code, notes, and snippets.

@ysf
Created September 25, 2009 11:31
Show Gist options
  • Save ysf/193485 to your computer and use it in GitHub Desktop.
Save ysf/193485 to your computer and use it in GitHub Desktop.
usage: 'cap deploy:setup' for initialization. 'cap deploy' for updates and cap 'deploy:restart' for passenger restart. only the latest four releases are left on the server.
set :application, "application_name"
set :rails_env, 'production' # only needed for migrations
set :user, "webXX"
role :web, "serverX.domaincamp.de" # Your HTTP server, Apache/etc
role :app, "serverX.domaincamp.de" # This may be the same as your `Web` server
role :db, "serverX.domaincamp.de", :primary => true # This is where Rails migrations will run
set :scm, :git
set :repository, "git@yourgithost.tld:username/project/project.git"
set :deploy_via, :remote_cache
set :branch, "master"
ssh_options[:port] = 981
set :use_sudo, false
set :rake_path, "~/.gems/bin/rake"
set :gems_path, "/var/www/htdocs/#{user}/.gems:/usr/lib/ruby/gems/1.8"
## go for it ###################################################################
set :deploy_to, "/var/www/htdocs/#{user}/files/rails/#{application}"
set :symlink_path, "/var/www/htdocs/#{user}/html/rails/#{application}"
task :update_config, :roles => :app do
run "cp -Rf #{shared_path}/config/* #{release_path}/config/"
end
task :symlink_config, :roles => :app do
run "mkdir -p /var/www/htdocs/#{user}/html/rails"
run "ln -nfs #{current_path} #{symlink_path}"
end
after "deploy:setup", :symlink_config
after "deploy:update_code", :update_config
after "deploy", "deploy:seed" # run migrations and seed database with db/seeds.rb ( rails 2.3.4 feature )
after "deploy", "deploy:cleanup" # delete old releases, the latest four are left on the server
def rake( cmd )
run "cd #{symlink_path}; GEM_PATH=#{gems_path} RAILS_ENV=#{rails_env} #{rake_path} #{cmd}"
end
namespace :deploy do
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
task :seed, roles => :app, :except => { :no_release => true } do
rake "db:migrate"
rake "db:seed"
end
task :start do end
task :stop do end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment