capistrano deploy: let the user choose if running svc and svstat with sudo
Set svc_sudo to true in deploy_config.yml to use sudo. The default value will be false, so that if the parameter is missing capistrano will behave exactly as before.
This commit is contained in:
parent
23212e4146
commit
8632c8c40b
4 changed files with 31 additions and 9 deletions
|
|
@ -46,7 +46,7 @@ namespace :deploy do
|
|||
end
|
||||
|
||||
task :restart do
|
||||
thins = capture "svstat /service/thin*"
|
||||
thins = capture_svstat "/service/thin*"
|
||||
matches = thins.match(/(thin_\d+):/).captures
|
||||
|
||||
matches.each_with_index do |thin, index|
|
||||
|
|
@ -54,25 +54,25 @@ namespace :deploy do
|
|||
puts "sleeping for 20 seconds"
|
||||
sleep(20)
|
||||
end
|
||||
run "svc -t /service/#{thin}"
|
||||
svc "-t /service/#{thin}"
|
||||
end
|
||||
|
||||
run "svc -t /service/resque_worker*"
|
||||
svc "-t /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :kill do
|
||||
run "svc -k /service/thin*"
|
||||
run "svc -k /service/resque_worker*"
|
||||
svc "-k /service/thin*"
|
||||
svc "-k /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :start do
|
||||
run "svc -u /service/thin*"
|
||||
run "svc -u /service/resque_worker*"
|
||||
svc "-u /service/thin*"
|
||||
svc "-u /service/resque_worker*"
|
||||
end
|
||||
|
||||
task :stop do
|
||||
run "svc -d /service/thin*"
|
||||
run "svc -d /service/resque_worker*"
|
||||
svc "-d /service/thin*"
|
||||
svc "-d /service/resque_worker*"
|
||||
end
|
||||
|
||||
desc 'Copy resque-web assets to public folder'
|
||||
|
|
@ -93,3 +93,16 @@ after 'deploy:symlink' do
|
|||
deploy.copy_resque_assets
|
||||
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
|
||||
set :repository, config['repo']
|
||||
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
|
||||
set :repository, config['repo']
|
||||
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'
|
||||
rails_env: 'production'
|
||||
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:
|
||||
server: 'staging.example.com'
|
||||
deploy_to: '/var/www/diaspora'
|
||||
|
|
@ -18,3 +20,4 @@ staging:
|
|||
password: 'password'
|
||||
rails_env: 'staging'
|
||||
repo: 'git://github.com/diaspora/diaspora.git'
|
||||
svc_sudo: false
|
||||
|
|
|
|||
Loading…
Reference in a new issue