Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Write out worker pid to PIDFILE if specified.

  • Loading branch information...
commit 495d3fe21b05772ef67b22fcddff7b1af00f39cb 1 parent e6bdcb7
@christiannelson christiannelson authored dbackeus committed
Showing with 11 additions and 1 deletion.
  1. +7 −0 README.markdown
  2. +4 −1 lib/resque/tasks.rb
View
7 README.markdown
@@ -295,6 +295,13 @@ variable.
$ VVERBOSE=1 QUEUE=file_serve rake environment resque:work
+### Process IDs (PIDs)
+
+There are scenarios where it's helpful to record the PID of a resque
+worker process. Use the PIDFILE option for easy access to the PID:
+
+ $ PIDFILE=./resque.pid QUEUE=file_serve rake environment resque:work
+
### Priorities and Queue Lists
View
5 lib/resque/tasks.rb
@@ -8,7 +8,6 @@
task :work => :setup do
require 'resque'
- worker = nil
queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')
begin
@@ -19,6 +18,10 @@
abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
end
+ if ENV['PIDFILE']
+ File.open(ENV['PIDFILE'], 'w') { |f| f << Process.pid.to_s }
+ end
+
worker.log "Starting worker #{worker}"
worker.work(ENV['INTERVAL'] || 5) # interval, will block
Please sign in to comment.
Something went wrong with that request. Please try again.