Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add no-wait and force-kill-waittime options to Delayed::Comand #459

Open
wants to merge 1 commit into from

5 participants

@pacoguzman

I've added support to these options that are used for Daemons gems.

In our case we have some long running jobs that we don't want to be locked when the process is killed on a new deployment, with these we avoid that problem and the process is going to still running after the current job is completed. Later our monitor system will start a new process.

What do you think? is this too specific to the daemons gem? I don't find another way to pass options to the daemons gem

@pacoguzman

Some news with this

@asamix

I want to use this. Because, delayed_job's process was frequently force-killed on restart them.

@adamniedzielski

Will you accept this pull request if I rewrite it to work with current master? I think that it's really useful especially when you suffer from "process with pid X won't stop, we forcefully kill it" as described in #593 /cc @albus522

@tiredenzo

Is it possible to resolve conflicts in this
I think that this feature should be integrated please.

@albus522
Owner

Does this require a specific min version of the daemons gem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 2 deletions.
  1. +17 −2 lib/delayed/command.rb
View
19 lib/delayed/command.rb
@@ -12,7 +12,8 @@ class Command
def initialize(args)
@options = {
:quiet => true,
- :pid_dir => "#{Rails.root}/tmp/pids"
+ :pid_dir => "#{Rails.root}/tmp/pids",
+ :force_kill_waittime => 20
}
@worker_count = 1
@@ -61,6 +62,12 @@ def initialize(args)
opts.on('--queue=queue', "Specify which queue DJ must look up for jobs") do |queue|
@options[:queues] = queue.split(',')
end
+ opts.on('--no-wait', "Avoid killing the process if a current job is long run") do
+ @no_wait = true
+ end
+ opts.on('--kill-waitime', "Amount of time to wait to kill the process after sending the stop command") do |n|
+ @options[:force_kill_waittime] = n.to_i
+ end
end
@args = opts.parse!(args)
end
@@ -84,7 +91,15 @@ def daemonize
def run_process(process_name, dir)
Delayed::Worker.before_fork
- Daemons.run_proc(process_name, :dir => dir, :dir_mode => :normal, :monitor => @monitor, :ARGV => @args) do |*args|
+
+ opts = { :dir => dir,
+ :dir_mode => :normal,
+ :monitor => @monitor,
+ :no_wait => @no_wait,
+ :force_kill_waittime => @options.delete(:force_kill_waittime),
+ :ARGV => @args }
+
+ Daemons.run_proc(process_name, opts) do |*args|
$0 = File.join(@options[:prefix], process_name) if @options[:prefix]
run process_name
end
Something went wrong with that request. Please try again.