Created
October 5, 2012 01:59
-
-
Save albertogg/3837646 to your computer and use it in GitHub Desktop.
Capistrano deploy.rb with rbenv, unicorn and nginx.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/setup' | |
server "some-ip", :web, :app, :db, primary: true | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
set :application, "application-name" | |
set :repository, "git@git" | |
set :user, "deploy" # As defined on your server | |
set :deploy_to, "/home/#{user}/app/#{application}" # Directory in which the deployment will take place | |
set :deploy_via, :remote_cache | |
set :use_sudo, true | |
set :assets_path, "#{deploy_to}/shared/app" | |
set :scm, "git" | |
set :branch, "master" | |
set :default_environment, { | |
'PATH' => "/home/deploy/.rbenv/shims:/home/deploy/.rbenv/bin:$PATH" | |
} | |
namespace :deploy do | |
task :preowner do | |
run "mkdir -p #{release_path}/tmp/cache" | |
run "mkdir -p #{release_path}/tmp/sessions" | |
run "mkdir -p #{release_path}/tmp/sockets" | |
end | |
task :chowner do | |
sudo "chown -R deploy:deploy #{deploy_to}/current/tmp/*" | |
end | |
task :start do | |
sudo "/etc/init.d/unicorn start" | |
end | |
task :stop do | |
sudo "/etc/init.d/unicorn stop" | |
end | |
task :restart do | |
sudo '/bin/bash -c "/etc/init.d/unicorn reload"' | |
end | |
end | |
after 'deploy:update_code', 'deploy:preowner' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment