Skip to content

Instantly share code, notes, and snippets.

@caged

caged/deploy.rb Secret

Created January 14, 2011 04:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caged/d683cb464874f4ab33ee to your computer and use it in GitHub Desktop.
Save caged/d683cb464874f4ab33ee to your computer and use it in GitHub Desktop.
Deploy file for portlandcrime.com
$:.unshift(File.expand_path('./lib', ENV['rvm_path'])) # Add RVM's lib directory to the load path.
require 'rvm/capistrano' # Load RVM's capistrano plugin.
require 'bundler/capistrano'
require 'whenever/capistrano'
set :whenever_command, "bundle exec whenever"
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in.
set :rvm_type, :user
set :application, "pdxcrime"
set :repository, "YOUR_REPO"
set :scm, :git
set :branch, 'master'
set :user, 'YOUR_USER'
set :use_sudo, false
set :deploy_via, :remote_cache
set :deploy_to, "/home/deploy/pdxcrime"
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`
role :web, "pdxcrime.com" # Your HTTP server, Apache/etc
role :app, "pdxcrime.com" # This may be the same as your `Web` server
role :db, "pdxcrime.com", :primary => true # This is where Rails migrations will run
ssh_options[:forward_agent] = true
# If you are using Passenger mod_rails uncomment this:
# if you're still using the script/reapear helper you will need
# these http://github.com/rails/irs_process_scripts
# namespace :deploy do
# task :start do ; end
# task :stop do ; end
# task :restart, :roles => :app, :except => { :no_release => true } do
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
# end
# end
after 'deploy:symlink', 'jammit:precache_assets'
after 'deploy:setup', 'pagecache:create'
after 'deploy:update_code','pagecache:symlink'
after 'deploy:cleanup','pagecache:flush'
namespace :jammit do
desc 'Precache static assets'
task :precache_assets do
# Not sure why I have to specify an absolute path for jammit?
run "cd #{current_path} && bundle exec jammit -c #{File.join(current_path, 'config', 'assets.yml')}"
end
end
namespace :pagecache do
task :create, :roles => :app do
run "umask 02 && mkdir -p #{shared_path}/cache"
end
task :symlink, :roles => :app, :except => {:no_release => true, :no_symlink => true} do
run "cd #{release_path} && ln -nfs #{shared_path}/cache #{release_path}/public/cache"
end
task :flush, :roles => :app do
run "rm -rf #{shared_path}/cache/*"
end
end
#############################################################
# Passenger
#############################################################
namespace :deploy do
desc "Symlink config files"
task :before_symlink do
run "ln -s #{shared_path}/system/database.mongo.yml #{release_path}/config/database.mongo.yml"
end
# Restart passenger on deploy
desc "Restarting Passenger 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 Passenger"
task t, :roles => :app do ; end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment