Skip to content


Subversion checkout URL

You can clone with
Download ZIP


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

wants to merge 1 commit into from

5 participants


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


Some news with this


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


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


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


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
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(',')
+ 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
@args = opts.parse!(args)
@@ -84,7 +91,15 @@ def daemonize
def run_process(process_name, dir)
- 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
Something went wrong with that request. Please try again.