Skip to content

Commit

Permalink
Allow for a custom pid directory to be specified on the command line.
Browse files Browse the repository at this point in the history
The problem with using #{RAILS_ROOT}/tmp/pids is that this dir changes with each deploy, so you have to make sure DJ is stopped before deploy and restarted after. Allowing for a pid dir that is stable makes it easier to use monitoring tools like Monit.
  • Loading branch information
Brad Greenlee committed Apr 9, 2010
1 parent 2558b48 commit bd8c4ae
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/delayed/command.rb
Expand Up @@ -8,7 +8,10 @@ class Command

def initialize(args)
@files_to_reopen = []
@options = {:quiet => true}
@options = {
:quiet => true,
:pid_dir => "#{RAILS_ROOT}/tmp/pids"
}

@worker_count = 1

Expand All @@ -31,6 +34,9 @@ def initialize(args)
opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|
@worker_count = worker_count.to_i rescue 1
end
opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
@options[:pid_dir] = dir
end
end
@args = opts.parse!(args)
end
Expand All @@ -42,7 +48,7 @@ def daemonize
@files_to_reopen << file unless file.closed?
end

dir = "#{RAILS_ROOT}/tmp/pids"
dir = @options[:pid_dir]
Dir.mkdir(dir) unless File.exists?(dir)

worker_count.times do |worker_index|
Expand Down

0 comments on commit bd8c4ae

Please sign in to comment.