Skip to content

Commit

Permalink
Daemonizes when BACKGROUND environment var is set
Browse files Browse the repository at this point in the history
  • Loading branch information
cleishm committed Aug 24, 2011
1 parent 78273c2 commit 60b157d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/resque/tasks.rb
Expand Up @@ -18,6 +18,10 @@
abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
end

if ENV['BACKGROUND']
Process.daemon(true)
end

if ENV['PIDFILE']
File.open(ENV['PIDFILE'], 'w') { |f| f << worker.pid }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/resque/worker.rb
Expand Up @@ -470,7 +470,7 @@ def hostname

# Returns Integer PID of running worker
def pid
@pid ||= to_s.split(":")[1].to_i
Process.pid
end

# Returns an Array of string pids of all the other workers on this
Expand Down

0 comments on commit 60b157d

Please sign in to comment.