Heroku Delayed-Job Auto-Scale

Deroku_dj_auto_scale allows automatic scaling of Delayed Job workers on Heroku (http://www.heroku.com/). The code heavily borrows from something I once came across on the internet. It also requires a custom version of delayed_job I created (https://github.com/joelbasson/delayed_job) which provides another hook signaling completion of the job. This change will hopefully be rolled into the original delayed_job from collectiveidea in the future.

Setup

Add the following to the class that will have auto-scalling DJ workers


	class Mailer < ActionMailer::Base
	  extend HerokuDjAutoScale
	
	  def my_function
		etc
	  end
	
	  ...
	end

You need to define the following variables in your config/environments/production.rb


ENV['HEROKU_USER'] = '[email protected]' 
ENV['HEROKU_PASS'] = 'yourherokupassword'
ENV['HEROKU_APP'] = 'yourappsnameinheroku'
ENV['USE_HEROKU_SCALING'] = 'true'

and in config/environments/development.rb set this to false


ENV['HEROKU_USER'] = 'doesntmatter' 
ENV['HEROKU_PASS'] = 'doesntmatter'
ENV['HEROKU_APP'] = 'doesntmatter'
ENV['USE_HEROKU_SCALING'] = 'false'

Enjoy