Merge pull request #2826 from nolith/capistrano
fixed and improved capistrano recipe [ci skip]
This commit is contained in:
commit
fc8a9a7b58
4 changed files with 37 additions and 11 deletions
|
|
@ -20,6 +20,7 @@ set :use_sudo, false
|
||||||
set :scm_verbose, true
|
set :scm_verbose, true
|
||||||
set :repository_cache, "remote_cache"
|
set :repository_cache, "remote_cache"
|
||||||
set :deploy_via, :checkout
|
set :deploy_via, :checkout
|
||||||
|
set :bundle_without, [:development, :test, :heroku]
|
||||||
|
|
||||||
# Figure out the name of the current local branch
|
# Figure out the name of the current local branch
|
||||||
def current_git_branch
|
def current_git_branch
|
||||||
|
|
@ -40,38 +41,41 @@ namespace :deploy do
|
||||||
end
|
end
|
||||||
|
|
||||||
task :bundle_static_assets do
|
task :bundle_static_assets do
|
||||||
run "cd #{current_path} && sass --update public/stylesheets/sass:public/stylesheets"
|
run "cd #{current_path} && bundle exec sass --update public/stylesheets/sass:public/stylesheets"
|
||||||
run "cd #{current_path} && bundle exec jammit"
|
run "cd #{current_path} && bundle exec jammit"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :restart do
|
task :restart do
|
||||||
thins = capture "svstat /service/thin*"
|
thins = capture_svstat "/service/thin*"
|
||||||
matches = thins.match(/(thin_\d+):/).captures
|
matches = thins.split("\n").inject([]) do |list, line|
|
||||||
|
m = line.match(/(thin_\d+):/)
|
||||||
|
list << m.captures[0] unless m.nil?
|
||||||
|
end
|
||||||
|
|
||||||
matches.each_with_index do |thin, index|
|
matches.each_with_index do |thin, index|
|
||||||
unless index == 0
|
unless index == 0
|
||||||
puts "sleeping for 20 seconds"
|
puts "sleeping for 20 seconds"
|
||||||
sleep(20)
|
sleep(20)
|
||||||
end
|
end
|
||||||
run "svc -t /service/#{thin}"
|
svc "-t /service/#{thin}"
|
||||||
end
|
end
|
||||||
|
|
||||||
run "svc -t /service/resque_worker*"
|
svc "-t /service/resque_worker*"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :kill do
|
task :kill do
|
||||||
run "svc -k /service/thin*"
|
svc "-k /service/thin*"
|
||||||
run "svc -k /service/resque_worker*"
|
svc "-k /service/resque_worker*"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :start do
|
task :start do
|
||||||
run "svc -u /service/thin*"
|
svc "-u /service/thin*"
|
||||||
run "svc -u /service/resque_worker*"
|
svc "-u /service/resque_worker*"
|
||||||
end
|
end
|
||||||
|
|
||||||
task :stop do
|
task :stop do
|
||||||
run "svc -d /service/thin*"
|
svc "-d /service/thin*"
|
||||||
run "svc -d /service/resque_worker*"
|
svc "-d /service/resque_worker*"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Copy resque-web assets to public folder'
|
desc 'Copy resque-web assets to public folder'
|
||||||
|
|
@ -92,3 +96,16 @@ after 'deploy:symlink' do
|
||||||
deploy.copy_resque_assets
|
deploy.copy_resque_assets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def maybe_sudo(cmd)
|
||||||
|
"#{svc_sudo ? sudo : ''} #{cmd}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def svc(opts)
|
||||||
|
run(maybe_sudo("svc #{opts}"))
|
||||||
|
end
|
||||||
|
|
||||||
|
def capture_svstat(opts)
|
||||||
|
capture(maybe_sudo("svstat #{opts}"))
|
||||||
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,6 @@ if config['branch']
|
||||||
end
|
end
|
||||||
set :repository, config['repo']
|
set :repository, config['repo']
|
||||||
server config['server'], :app, :web, :db, :primary => true
|
server config['server'], :app, :web, :db, :primary => true
|
||||||
|
set :svc_sudo, (config['svc_sudo'] || false)
|
||||||
|
default_run_options[:pty] = true if svc_sudo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,6 @@ if config['branch']
|
||||||
end
|
end
|
||||||
set :repository, config['repo']
|
set :repository, config['repo']
|
||||||
server config['server'], :app, :web, :db, :primary => true
|
server config['server'], :app, :web, :db, :primary => true
|
||||||
|
set :svc_sudo, (config['svc_sudo'] || false)
|
||||||
|
default_run_options[:pty] = true if svc_sudo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ production:
|
||||||
password: 'password'
|
password: 'password'
|
||||||
rails_env: 'production'
|
rails_env: 'production'
|
||||||
repo: 'git://github.com/diaspora/diaspora.git'
|
repo: 'git://github.com/diaspora/diaspora.git'
|
||||||
|
#set svc_sudo to true if you want to run scv and svstat with sudo. default: false
|
||||||
|
svc_sudo: false
|
||||||
staging:
|
staging:
|
||||||
server: 'staging.example.com'
|
server: 'staging.example.com'
|
||||||
deploy_to: '/var/www/diaspora'
|
deploy_to: '/var/www/diaspora'
|
||||||
|
|
@ -18,3 +20,4 @@ staging:
|
||||||
password: 'password'
|
password: 'password'
|
||||||
rails_env: 'staging'
|
rails_env: 'staging'
|
||||||
repo: 'git://github.com/diaspora/diaspora.git'
|
repo: 'git://github.com/diaspora/diaspora.git'
|
||||||
|
svc_sudo: false
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue