Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit 6790e8c3328f797a910082fc7db461225c84dbea 1 parent 4dbddcb
Tatsuya Ono authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/resque/tasks.rb
13 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

Ryan Biesemeyer

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

Tatsuya Ono
Owner

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.
Something went wrong with that request. Please try again.