Skip to content
Browse files

whitespace

  • Loading branch information...
1 parent 602e5c8 commit 6ef0fc6986a57760bfa402ae839082b679d97652 @bkeepers bkeepers committed Nov 25, 2010
Showing with 12 additions and 12 deletions.
  1. +12 −12 lib/delayed/command.rb
View
24 lib/delayed/command.rb
@@ -5,17 +5,17 @@
module Delayed
class Command
attr_accessor :worker_count
-
+
def initialize(args)
@files_to_reopen = []
@options = {
:quiet => true,
:pid_dir => "#{Rails.root}/tmp/pids"
}
-
+
@worker_count = 1
@monitor = false
-
+
opts = OptionParser.new do |opts|
opts.banner = "Usage: #{File.basename($0)} [options] start|stop|restart|run"
@@ -47,17 +47,17 @@ def initialize(args)
end
@args = opts.parse!(args)
end
-
+
def daemonize
Delayed::Worker.backend.before_fork
ObjectSpace.each_object(File) do |file|
@files_to_reopen << file unless file.closed?
end
-
+
dir = @options[:pid_dir]
Dir.mkdir(dir) unless File.exists?(dir)
-
+
if @worker_count > 1 && @options[:identifier]
raise ArgumentError, 'Cannot specify both --number-of-workers and --identifier'
elsif @worker_count == 1 && @options[:identifier]
@@ -70,16 +70,16 @@ def daemonize
end
end
end
-
+
def run_process(process_name, dir)
Daemons.run_proc(process_name, :dir => dir, :dir_mode => :normal, :monitor => @monitor, :ARGV => @args) do |*args|
run process_name
end
end
-
+
def run(worker_name = nil)
Dir.chdir(Rails.root)
-
+
# Re-open file handles
@files_to_reopen.each do |file|
begin
@@ -88,10 +88,10 @@ def run(worker_name = nil)
rescue ::Exception
end
end
-
+
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))
Delayed::Worker.backend.after_fork
-
+
worker = Delayed::Worker.new(@options)
worker.name_prefix = "#{worker_name} "
worker.start
@@ -100,6 +100,6 @@ def run(worker_name = nil)
STDERR.puts e.message
exit 1
end
-
+
end
end

0 comments on commit 6ef0fc6

Please sign in to comment.
Something went wrong with that request. Please try again.