From 83d66bf7e035be80b6b26fa87aa8983d9f9996fd Mon Sep 17 00:00:00 2001 From: Zach Baker Date: Mon, 6 Jul 2015 13:32:25 -0700 Subject: [PATCH 1/4] Make "nohup" non-default optional to address #101 The interaction between this gem and capistrano-rbenv causes problems in this configuration. Allowing "nohup" to be left out is a workaround. See https://github.com/sshingler/capistrano-resque/issues/101 for why this is so. --- lib/capistrano-resque/capistrano_integration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano-resque/capistrano_integration.rb b/lib/capistrano-resque/capistrano_integration.rb index 15ecad3..c5347b1 100644 --- a/lib/capistrano-resque/capistrano_integration.rb +++ b/lib/capistrano-resque/capistrano_integration.rb @@ -50,7 +50,7 @@ def start_command(queue, pid) PIDFILE=#{pid} BACKGROUND=yes \ #{"VERBOSE=1 " if fetch(:resque_verbose)}\ INTERVAL=#{interval} \ - nohup #{fetch(:bundle_cmd, "bundle")} exec rake \ + #{fetch(:nohup_cmd, "")} #{fetch(:bundle_cmd, "bundle")} exec rake \ #{"environment " if fetch(:resque_environment_task)}\ resque:work #{output_redirection}" end @@ -82,7 +82,7 @@ def start_scheduler(pid) #{"VERBOSE=1 " if fetch(:resque_verbose)}\ MUTE=1 \ #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}\ - nohup #{fetch(:bundle_cmd, "bundle")} exec rake \ + #{fetch(:nohup_cmd, "")} #{fetch(:bundle_cmd, "bundle")} exec rake \ #{"environment " if fetch(:resque_environment_task)}\ resque:scheduler #{output_redirection}" end From 49e70ea37aa80a8104ea56693983910c7619af34 Mon Sep 17 00:00:00 2001 From: Zach Baker Date: Mon, 6 Jul 2015 14:34:29 -0700 Subject: [PATCH 2/4] Remove "nohup" from rake task to address #101 The interaction between this gem and capistrano-rbenv causes problems in this configuration. Removing "nohup" is a workaround. See https://github.com/sshingler/capistrano-resque/issues/101 for why this is so. --- lib/capistrano-resque/tasks/capistrano-resque.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano-resque/tasks/capistrano-resque.rake b/lib/capistrano-resque/tasks/capistrano-resque.rake index b1f6490..1b74ec5 100644 --- a/lib/capistrano-resque/tasks/capistrano-resque.rake +++ b/lib/capistrano-resque/tasks/capistrano-resque.rake @@ -70,7 +70,7 @@ namespace :resque do number_of_workers.times do pid = "#{fetch(:resque_pid_path)}/resque_work_#{worker_id}.pid" within current_path do - execute :nohup, %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} + execute %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} end worker_id += 1 end @@ -130,7 +130,7 @@ namespace :resque do create_pid_path pid = "#{fetch(:resque_pid_path)}/scheduler.pid" within current_path do - execute :nohup, %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} + execute %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} end end end From ffa1cea0988443b0b2a73afd514f99c98f8288e5 Mon Sep 17 00:00:00 2001 From: Lucas gomide Date: Wed, 28 Oct 2015 08:18:41 -0200 Subject: [PATCH 3/4] Go to release_path and execute command --- lib/capistrano-resque/tasks/capistrano-resque.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano-resque/tasks/capistrano-resque.rake b/lib/capistrano-resque/tasks/capistrano-resque.rake index 1b74ec5..e070edf 100644 --- a/lib/capistrano-resque/tasks/capistrano-resque.rake +++ b/lib/capistrano-resque/tasks/capistrano-resque.rake @@ -70,7 +70,7 @@ namespace :resque do number_of_workers.times do pid = "#{fetch(:resque_pid_path)}/resque_work_#{worker_id}.pid" within current_path do - execute %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} + execute %{#{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} end worker_id += 1 end @@ -130,7 +130,7 @@ namespace :resque do create_pid_path pid = "#{fetch(:resque_pid_path)}/scheduler.pid" within current_path do - execute %{#{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} + execute %{#{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} end end end From d7df527a968143f38dca30e58e32f35876d44c8c Mon Sep 17 00:00:00 2001 From: Lucas gomide Date: Wed, 28 Oct 2015 08:20:53 -0200 Subject: [PATCH 4/4] Add cd command --- lib/capistrano-resque/tasks/capistrano-resque.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/capistrano-resque/tasks/capistrano-resque.rake b/lib/capistrano-resque/tasks/capistrano-resque.rake index e070edf..30aea8a 100644 --- a/lib/capistrano-resque/tasks/capistrano-resque.rake +++ b/lib/capistrano-resque/tasks/capistrano-resque.rake @@ -70,7 +70,7 @@ namespace :resque do number_of_workers.times do pid = "#{fetch(:resque_pid_path)}/resque_work_#{worker_id}.pid" within current_path do - execute %{#{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} + execute %{cd #{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} QUEUE="#{queue}" PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}INTERVAL=#{fetch(:interval)} #{"environment " if fetch(:resque_environment_task)}resque:work #{output_redirection}} end worker_id += 1 end @@ -130,7 +130,7 @@ namespace :resque do create_pid_path pid = "#{fetch(:resque_pid_path)}/scheduler.pid" within current_path do - execute %{#{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} + execute %{cd #{release_path} && #{SSHKit.config.command_map[:rake]} RACK_ENV=#{rails_env} RAILS_ENV=#{rails_env} PIDFILE=#{pid} BACKGROUND=yes #{"VERBOSE=1 " if fetch(:resque_verbose)}MUTE=1 #{"DYNAMIC_SCHEDULE=yes " if fetch(:resque_dynamic_schedule)}#{"environment " if fetch(:resque_environment_task)}resque:scheduler #{output_redirection}} end end end