Skip to content

Instantly share code, notes, and snippets.

@geekontheway
Created February 25, 2012 02:05
Show Gist options
  • Save geekontheway/1905263 to your computer and use it in GitHub Desktop.
Save geekontheway/1905263 to your computer and use it in GitHub Desktop.
capistrano-with-passenger-stand-alone
# -*- encoding : utf-8 -*-
$:.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.
set :rvm_ruby_string, '1.9.2' # Or whatever env you want it to run in.
require 'bundler/capistrano'
set :application, "yourapp"
set :use_sudo, false
set :scm, :git
set :deploy_via, :remote_cache
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
set :git_shallow_clone, 1
set :git_enable_submodules, 1
role :web, "foo.foo.foo.foo" # Your HTTP server, Apache/etc
role :app, "foo.foo.foo.foo" # This may be the same as your `Web` server
role :db, "foo.foo.foo.foo", :primary => true # This is where Rails migrations will run
set :user, "root"
set :repository, "[email protected]:yourname/yourapp.git"
set :branch, "master"
set :deploy_to, "/var/rails/yourapp"
# tasks
namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path};passenger start -a 127.0.0.1 -p 3001 -d -e production" # In case of Phunsion Passenger standalone
end
task :stop, :roles => :app do
run "kill -QUIT `cat #{current_path}/tmp/pids/passenger.3001.pid`"
end
desc "Compile assets"
task :assets do
run "cd #{release_path}; RAILS_ENV=production bundle exec rake assets:precompile"
end
desc "Restart Application"
task :restart, :roles => :app do
run "kill -USR2 `cat #{current_path}/tmp/pids/passenger.3001.pid`"
end
desc "Symlink shared resources on each release"
task :symlink_shared, :roles => :app do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/system #{release_path}/public/system"
end
end
after 'deploy:update_code', 'deploy:symlink_shared'
after "deploy:symlink_shared", "deploy:assets"
namespace :db do
desc "migrate db"
task :migrate, :roles => :app do
run "cd #{release_path} && RAILS_ENV=production rake db:migrate"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment