lib/negroku/capistrano/tasks/eye/delayed_job.rake in negroku-2.7.1 vs lib/negroku/capistrano/tasks/eye/delayed_job.rake in negroku-2.8.0
- old
+ new
@@ -1,43 +1,39 @@
#########
## Adds support to monitor delayed_job processes through eye
#########
-def delayed_job_args
- args = []
- args << "--queues=#{fetch(:delayed_job_queues).join(',')}" unless fetch(:delayed_job_queues).nil?
- args << "--prefix=#{fetch(:delayed_job_prefix)}" unless fetch(:delayed_job_prefix).nil?
- args << fetch(:delayed_job_pools, {}).map {|k,v| "--pool=#{k}:#{v}"}.join(' ') unless fetch(:delayed_job_pools).nil?
- args.join(' ')
-end
-def delayed_job_bin
- "#{fetch(:delayed_job_bin_path)}/delayed_job"
-end
+# Watch the delayed_job processes using the build in template
+namespace :delayed_job do
+ # Remove the multi process arg
+ def delayed_job_single_args
+ delayed_job_args.gsub(/-n\s\d\s*/, "")
+ end
-def delayed_job_start_command
- "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} #{delayed_job_args} -i \#{i} start"
-end
+ def delayed_job_start_command
+ "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} #{delayed_job_single_args} -i \#{i} start"
+ end
-def delayed_job_stop_command
- "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} -i \#{i} stop"
-end
+ def delayed_job_stop_command
+ "#{fetch(:rbenv_prefix)} bundle exec #{delayed_job_bin} #{delayed_job_single_args} -i \#{i} stop"
+ end
-# Watch the delayed_job processes using the build in template
-namespace :eye do
task :watch_process do
-
- watch_process(:delayed_job, {
- start_command: delayed_job_start_command,
- stop_command: delayed_job_stop_command
- })
-
+ watch_process(:delayed_job, start_command: delayed_job_start_command,
+ stop_command: delayed_job_stop_command,
+ start_timeout: fetch(:eye_delayed_job_start_timeout, 60),
+ stop_timeout: fetch(:eye_delayed_job_stop_timeout, 30),
+ restart_timeout: fetch(:eye_delayed_job_restart_timeout, 30),
+ start_grace: fetch(:eye_delayed_job_start_grace, 100),
+ stop_grace: fetch(:eye_delayed_job_stop_grace, 30),
+ restart_grace: fetch(:eye_delayed_job_restart_grace, 30),
+ workers: fetch(:delayed_job_workers, 1)
+ )
end
-end
-# Override start, restart and stop delayed_job tasks to so they call
-# the eye equivalents
-namespace :delayed_job do
- ['start','restart','stop'].each do |cmd|
+ # Override start, restart and stop delayed_job tasks to so they call
+ # the eye equivalents
+ ['start', 'restart', 'stop'].each do |cmd|
if Rake::Task.task_defined?("delayed_job:#{cmd}")
Rake::Task["delayed_job:#{cmd}"].clear_actions
# Reload or restart delayed_job after the application is published
desc "using eye"
task cmd do