Giter Site home page Giter Site logo

workless's Introduction

Workless

This is an addon for delayed_job (2.1.0.pre2) http://github.com/collectiveidea/delayed_job/tree/v2.1.0.pre2
It is designed to be used when you’re using Heroku as a host and have the need to do background work with delayed job but you dont want to leave the workers running all the time as it costs money.

You basically add the gem to your project and the rest is taken care of for you given a few CONFIG vars set on Heroku.

There are already a few of these out there, notably @mtravers’ cheepnis http://github.com/mtravers/cheepnis and the autoscale branch of delayed_job by @pedro http://github.com/pedro/delayed_job/tree/autoscaling

This one takes bits from both and is helping me understand gem and plugin development. It’s built for rails 3 on the delayed_job 2.1.0.pre2 tag but don’t see why it wouldn’t work on rails 2 as well as it hooks into the callbacks of the Delayed::Job ActiveRecord class to turn workers on and off based on the creation and destruction of jobs.

Installation

Add the gem to your project Gemfile and update your bundle

gem "workless"

Add your Heroku username / password as config vars to your Heroku instance, the same one you log in to Heroku with

heroku config:add HEROKU_USER=<your username> HEROKU_PASSWORD=<your password>

And for cedar apps add the app name

heroku config:add APP_NAME=<your app name>

Failing Jobs

In the case of failed jobs Workless will only shut down the dj worker if all attempts have been tried. By default Delayed Job will try 25 times to process a job with ever increasing time delays between each unsucessful attempt. Because of this Workless configures Delayed Job to try failed jobs only 3 times to reduce the amount of time a worker can be running while trying to process them.

Configuration

Workless can be disabled by using the null scaler that will ignore the workers requests to scale up and down. In an environment file add this in the config block:

config.after_initialize do 
  Delayed::Job.scaler = :null
end

There are three other scalers included. Note that if you are running on the Aspen or Bamboo stacks on Heroku and you don’t explicitly specify the scaler, the heroku scaler will be used automatically.

Delayed::Job.scaler = :heroku
Delayed::Job.scaler = :heroku_cedar
Delayed::Job.scaler = :local

The local scaler uses @adamwiggins rush library http://github.com/adamwiggins/rush to start and stop workers on a local machine

The heroku scaler works on the Aspen and Bamboo stacks while the heroku_cedar scaler only works on the new Cedar stack.

Note on Patches/Pull Requests

  • Please fork the project, as you can see there are no tests and at present I don’t know how to go about adding them so any advice would be welcome.
  • Make your feature addition or bug fix.
  • Commit, do not mess with rakefile, version, or history.
    (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request.

Copyright

Copyright © 2010 lostboy. See LICENSE for details.

workless's People

Contributors

3dd13 avatar axs89 avatar chrisnicola avatar christophercotton avatar fphilipe avatar lostboy avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.