fix resque task user switching

This commit is contained in:
wvengen 2014-02-25 22:49:18 +01:00
parent d9326dd984
commit cd32f702b0

View file

@ -9,13 +9,16 @@ namespace :resque do
desc "#{action.capitalize} Resque workers" desc "#{action.capitalize} Resque workers"
task action => ['deploy:set_rails_env'] do task action => ['deploy:set_rails_env'] do
on roles(:resque), in: :groups do on roles(:resque), in: :groups do
within current_path do
cmd = command(:rake, "resque:#{action}_workers", "RAILS_ENV=#{fetch(:rails_env)}") SSHKit.config.command_map[:rake_as_run_user] =
if fetch(:run_user).nil? or fetch(:run_user) == local_user unless fetch(:run_user).nil? or fetch(:run_user) == fetch(:user)
execute cmd "sudo -u '#{fetch(:run_user)}' "
else else
execute 'sudo', '-u', fetch(:run_user), cmd ''
end end + SSHKit.config.command_map[:rake]
within current_path do
execute :rake_as_run_user, "'resque:#{action}_workers'", "RAILS_ENV='#{fetch(:rails_env)}'"
end end
end end
end end