-
-
Save raecoo/2429429 to your computer and use it in GitHub Desktop.
Resque Daemon Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
ENV['RAILS_ENV'] ||= 'development' | |
require File.expand_path('../../config/environment', __FILE__) | |
require 'daemon_spawn' | |
class ResqueWorkerDaemon < DaemonSpawn::Base | |
def start(args) | |
@worker = Resque::Worker.new('*') # Specify which queues this worker will process | |
@worker.verbose = 1 # Logging - can also set vverbose for 'very verbose' | |
@worker.work | |
end | |
def stop | |
@worker.try(:shutdown) | |
end | |
end | |
logs = Rails.root.join("log", "resque_workers.log").to_s | |
pids = Rails.root.join('tmp', 'pids', 'resque_workers.pid').to_s | |
ResqueWorkerDaemon.spawn!({ | |
:processes => 2, | |
:log_file => logs, | |
:pid_file => pids, | |
:sync_log => true, | |
:working_dir => Rails.root, | |
:singleton => true | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment