Permalink
Browse files

Output PID at the very beginning of task. If your application is

large, it takes time to initialize. Monitor app like God, Monit etc.
would think the worker is not launch.
  • Loading branch information...
1 parent 4dbddcb commit 6790e8c3328f797a910082fc7db461225c84dbea @ono committed Mar 2, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/resque/tasks.rb
View
@@ -5,7 +5,14 @@
task :setup
desc "Start a Resque worker"
- task :work => [ :preload, :setup ] do
+ task :work do
+ if ENV['PIDFILE']
+ File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid }
+ end
+
+ Rake::Task['resque:preload'].invoke
+ Rake::Task['resque:setup'].invoke
+
require 'resque'
queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')
@@ -25,10 +32,6 @@
Process.daemon(true)
end
- if ENV['PIDFILE']
- File.open(ENV['PIDFILE'], 'w') { |f| f << worker.pid }
- end
-
worker.log "Starting worker #{worker}"
worker.work(ENV['INTERVAL'] || 5) # interval, will block

2 comments on commit 6790e8c

@yaauie
yaauie commented on 6790e8c Mar 2, 2012

@ono I'm a fan of using rake's dependent tasks, so I re-implemented it that way here: yaauie@7ef4654

@ono
Owner
ono replied Mar 2, 2012

Thanks! That's a way better indeed.

@yaauie Can you send pull-request to defunkt/resque with it? I will close the one I've sent.

Please sign in to comment.