Skip to content

Instantly share code, notes, and snippets.

@BDQ
Created December 1, 2011 13:39
Show Gist options
  • Save BDQ/1416792 to your computer and use it in GitHub Desktop.
Save BDQ/1416792 to your computer and use it in GitHub Desktop.
Capistrano Recipe for Spree 0.70.0 - Single Server
$:.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"
load 'deploy/assets'
set :application, "YOUR_APP_NAME"
set :user, 'spree'
set :group, 'www-data'
set :domain, "#{application}.spreeworks.com"
set :rvm_ruby_string, 'ree-1.8.7-2011.03'
set :scm, :git
role :web, domain
role :app, domain
role :db, domain, :primary => true
set :repository, "YOUR_GIT_URL"
set :branch, "master"
set :deploy_to, "/data/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
default_run_options[:pty] = true
set :ssh_options, { :forward_agent => true }
namespace :foreman do
desc "Export the Procfile to Ubuntu's upstart scripts"
task :export, :roles => :app do
run "cd #{current_path} && bundle exec foreman export upstart /etc/init -a #{application} -u spree"
end
desc "Start the application services"
task :start, :roles => :app do
sudo "start #{application}"
end
desc "Stop the application services"
task :stop, :roles => :app do
sudo "stop #{application}"
end
desc "Restart the application services"
task :restart, :roles => :app do
sudo "restart #{application}"
end
end
namespace :deploy do
desc "Symlink shared configs and folders on each release."
task :symlink_shared do
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
run "ln -nfs #{shared_path}/config/Procfile #{release_path}/Procfile"
run "ln -nfs #{shared_path}/assets #{release_path}/public/assets"
end
end
before 'deploy:assets:precompile', 'deploy:symlink_shared'
before 'deploy:start', 'foreman:export'
after 'deploy:start', 'foreman:start'
before 'deploy:restart', 'foreman:export'
after 'deploy:restart', 'foreman:restart'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment