Permalink
Browse files

further fortify against rogue worker methods, enable per worker confi…

…guration and merge seth patches
  • Loading branch information...
1 parent 89f70db commit a55973fde86cf22c19defa8acc53d077e9ba19a1 @gnufied committed Mar 28, 2009
Showing with 13 additions and 2 deletions.
  1. +4 −2 server/lib/master_proxy.rb
  2. +9 −0 server/lib/meta_worker.rb
@@ -112,10 +112,12 @@ def load_and_invoke(worker_name,p_method,data)
t_worker.send_request(data_request)
t_worker.send_request(exit_request)
end
- rescue LoadError
+ rescue LoadError => e
puts "no such worker #{worker_name}"
- rescue MissingSourceFile
+ puts e.backtrace.join("\n")
+ rescue MissingSourceFile => e
puts "no such worker #{worker_name}"
+ puts e.backtrace.join("\n")
return
end
end
@@ -129,6 +129,15 @@ def worker_init
if run_persistent_jobs?
add_periodic_timer(persistent_delay.to_i) { check_for_enqueued_tasks }
end
+ write_pid_file(t_worker_key)
+ end
+
+ def write_pid_file t_worker_key
+ key = [worker_name,t_worker_key].compact.join('_')
+ pid_file = "#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}_worker_#{key}.pid"
+ op = File.open(pid_file, "w")
+ op.write(Process.pid().to_s)
+ op.close
end
def initialize_logger

0 comments on commit a55973f

Please sign in to comment.