Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
Checking mergeability… Don’t worry, you can still create the pull request.
  • 6 commits
  • 7 files changed
  • 0 commit comments
  • 3 contributors
Commits on Jul 28, 2011
@meskyanichi meskyanichi Updated README. dc49643
Commits on Sep 12, 2011
@meskyanichi meskyanichi Adjusted README. 0df25a4
Commits on Sep 25, 2011
@meskyanichi meskyanichi Added Plegie to HireFire open source. 3f6ba60
Commits on Oct 10, 2011
@exitface exitface Add DM compatibility 1628539
Commits on Oct 16, 2011
@meskyanichi meskyanichi Merge pull request #37 from okbreathe/dm-compat
Add DM compatibility
Commits on Jan 09, 2012
@latentflip latentflip Alert if stale test. d79291f
@@ -7,8 +7,6 @@ HireFire - The Heroku Worker Manager
**High traffic example** say we have a high traffic application that needs to process a lot of jobs. There may be "traffic spikes" from time to time. In this case you can take advantage of the **job\_worker\_ratio**. Since this is application-specific, HireFire allows you to define how many workers there should be running, depending on the amount of queued jobs there are (see example configuration below). HireFire will then spin up more workers as traffic increases so it can work through the queue faster, then when the jobs are all finished, it'll shut down all the workers again until the next job gets queued (in which case it'll start with only a single worker again).
-**Enough with the examples!** Read on to see how to set it, and configure it to your scaling and money saving needs.
@@ -17,16 +15,27 @@ Author
Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log]( - The Heroku Worker Manager - BETA
+Please Donate!
+Please consider [DONATING]( to the HireFire project for the time and effort that was put in to developing the gem! Thanks!
+[![Donate to HireFire](](
+[]( - The Heroku Process Manager
+**This is not part of the open source HireFire**
+[HireFire]( is a hosted service which is based on HireFire(Open Source). The reason this project came about is because of Heroku's platform constraints which made the Open Source project quite unstable/unreliable and reduced performance dramatically on HTTP requests (slow response times when new jobs are being queued). It is also hard to allow both worker as well as dyno scaling, and manage that from within the same process.
-*This is not part of the "HireFire open source" project, but it could potentially help support my open source projects!*
+For this reason, I created a hosted web service, based on the open source project. Not only does it support **worker dyno scaling** but it also supports **web dyno scaling**. And next to Heroku's **Badious Bamboo** stack, it also supports Heroku's new stack, **Celadon Cedar**.
-I would like to announce the release of a **new service** I've been working on, called **HireFireApp**. The goal is essentially the same as the open source HireFire project, except that it's considered more **stable/reliable** and **a lot more performant**.
+If you're looking to scale either your web or worker dynos, on either Badious Bamboo or Celadon Cedar, be sure to check out the HireFire hosted service.
-The service is currently in beta, so feel free to create a free account and try it out!
-Check out the [official website]( for more information: [](
Setting it up
4 lib/hirefire/backend.rb
@@ -27,6 +27,10 @@ def self.included(base)
+ if defined?(::Delayed::Backend::DataMapper::Job)
+ base.send(:include, HireFire::Backend::DelayedJob::DataMapper)
+ end
if defined?(::Delayed::Backend::Mongoid::Job)
base.send(:include, HireFire::Backend::DelayedJob::Mongoid)
1  lib/hirefire/backend/delayed_job.rb
@@ -6,6 +6,7 @@ module DelayedJob
autoload :ActiveRecord, 'hirefire/backend/delayed_job/active_record'
autoload :ActiveRecord2, 'hirefire/backend/delayed_job/active_record_2'
autoload :Mongoid, 'hirefire/backend/delayed_job/mongoid'
+ autoload :DataMapper, 'hirefire/backend/delayed_job/data_mapper'
30 lib/hirefire/backend/delayed_job/data_mapper.rb
@@ -0,0 +1,30 @@
+# encoding: utf-8
+module HireFire
+ module Backend
+ module DelayedJob
+ module DataMapper
+ ##
+ # Counts the amount of queued jobs in the database,
+ # failed jobs are excluded from the sum
+ #
+ # @return [Fixnum] the amount of pending jobs
+ def jobs
+ ::Delayed::Job.count(:failed_at => nil, :run_at.lte =>
+ end
+ ##
+ # Counts the amount of jobs that are locked by a worker
+ # There is no other performant way to determine the amount
+ # of workers there currently are
+ #
+ # @return [Fixnum] the amount of (assumably working) workers
+ def working
+ ::Delayed::Job.count(:locked_by.not => nil)
+ end
+ end
+ end
+ end
14 lib/hirefire/environment.rb
@@ -42,6 +42,20 @@ def self.included(base)
after_update '',
:unless => { |job| job.failed_at.nil? }
+ elsif == "Delayed::Backend::DataMapper::Job"
+ base.send :extend, HireFire::Environment::DelayedJob::ClassMethods
+ base.class_eval do
+ after :create do
+ self.class.hirefire_hire
+ end
+ after :destroy do
+ end
+ after :update do
+ unless self.failed_at.nil?
+ end
+ end
Logger.message("#{ } detected!")
6 lib/hirefire/environment/base.rb
@@ -8,6 +8,10 @@ class Base
# Include HireFire::Backend helpers
include HireFire::Backend
+ def alert_if_stale
+ raise 'BAHHHHH' unless jobs.where('created_at >= ?', 2.minutes.ago).empty?
+ end
# This method gets invoked when a new job has been queued
@@ -63,6 +67,8 @@ def hire
jobs_count = jobs
workers_count = workers || return
+ alert_if_stale if jobs_count > 0
# Use "Standard Notation"
if not ratio.first[:when].respond_to? :call
9 lib/hirefire/initializer.rb
@@ -44,6 +44,15 @@ def self.initialize!
+ # If DelayedJob is using DataMapper, then include
+ # HireFire::Environment in to the DataMapper Delayed Job Backend
+ if defined?(::Delayed::Backend::DataMapper::Job)
+ ::Delayed::Backend::DataMapper::Job.
+ send(:include, HireFire::Environment).
+ send(:include, HireFire::Backend)
+ end
+ ##
# Load Delayed Job extensions, this will patch Delayed::Worker
# to implement the necessary hooks to invoke HireFire from
require 'hirefire/workers/delayed_job'

No commit comments for this range

Something went wrong with that request. Please try again.