27 lines
907 B
Text
27 lines
907 B
Text
|
|
# capistrano-resque could be used, but it does not support running resque as another user.
|
|
# If you want to run resque as another user, setup sudo to allow running commands as that user:
|
|
# deploy ALL=(foodsoft_user) NOPASSWD: ALL
|
|
# and set `:run_user` to the foodsoft user.
|
|
namespace :resque do
|
|
|
|
%w{start stop restart}.each do |action|
|
|
desc "#{action.capitalize} Resque workers"
|
|
task action => ['deploy:set_rails_env'] do
|
|
on roles(:resque), in: :groups do
|
|
|
|
SSHKit.config.command_map[:rake_as_run_user] =
|
|
unless fetch(:run_user).nil? || fetch(:run_user) == fetch(:user)
|
|
"sudo -u '#{fetch(:run_user)}' "
|
|
else
|
|
''
|
|
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
|