Skip to content

Instantly share code, notes, and snippets.

@mauricio
Created September 15, 2011 02:29
Show Gist options
  • Save mauricio/1218369 to your computer and use it in GitHub Desktop.
Save mauricio/1218369 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
root = File.expand_path( File.join( File.dirname(__FILE__), '..' ) )
Dir.chdir( root )
require 'rubygems'
gem 'daemons'
require 'daemons'
options = {
:dir_mode => :normal,
:dir => File.join( root, 'tmp', 'pids' ),
:log_dir => File.join( root, 'log' ),
:log_output => true,
:backtrace => true,
:multiple => false
}
ARGV << '--'
ARGV << root
puts "ARGV before #{ARGV.inspect}"
Daemons.run_proc("resque", options) do
puts "ARGV after #{ARGV.inspect}"
puts "Configured rails env - #{ENV['RAILS_ENV']}"
root = ARGV[2]
Dir.chdir( root )
require( File.join( root, 'config', 'environment') )
puts "Starting Resque at #{root} - Rails.env = #{Rails.env}"
require 'resque'
worker = Resque::Worker.new('*')
worker.verbose = '1'
worker.work(5)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment