| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is an addon for delayed_job (> 2.0.0) http://github.com/collectiveidea/delayed_job 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 don't want to leave the workers running all the time as it costs money.
By adding the gem to your project and configuring our Heroku app with some config variables workless should do the rest.
⚠️ The Legacy API will be sunset on April 15th, 2017 ⚠️ Please upgrade to version 2.0.0 as soon as you can. Version 2.0.0 is released on March 1st, 2017.
Version 2.2.0 changed the config for setting the Heroku API key. This will now reside in WORKLESS_API_KEY. Please change this key in your Heroku setup when upgrading this gem!
Workless should work correctly with Rubies 2.0.0 and up. It is compatible with Delayed Job since version 2.0.7 up to the latest version 4.1.2, the table below shows tested compatibility with ruby, rails and delayed_job
| Ruby | Rails | Delayed Job |
|---|---|---|
| 2.2.5 | 4.2 | 2.1.4 |
| 2.3.1 | 5.0 | 4.1.2 |
| 2.4.1 | 5.1 | 4.1.3 |
Add the workless gem and the delayed_job gem to your project Gemfile and update your bundle. Its is recommended to specify the gem version for delayed_job
gem "delayed_job_active_record" gem "workless", "~> 2.2.0"
gem "delayed_job_active_record" gem "workless", "~> 2.0.0"
If you don't specify delayed_job in your Gemfile workless will bring it in, most likely the latest version (4.1.2)
Add your Heroku app name / API key as config vars to your Heroku instance.
heroku config:add WORKLESS_API_KEY=yourapikey APP_NAME=yourherokuappname
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 unsuccessful 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.
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 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 local scaler also relies on script/delayed_job (which in turn requires the daemon gem). If you have been using foreman to run your workers, go back and see the delayed_job setup instructions.
The heroku scaler works on the Aspen and Bamboo stacks while the heroku_cedar scaler only works on the new Cedar stack.
As an experimental feature for the Cedar stack, Workless can scale to more than 1 worker based on the current work load. You just need to define these config variables on your app, setting the values you want:
heroku config:add WORKLESS_MAX_WORKERS=10 heroku config:add WORKLESS_MIN_WORKERS=0 heroku config:add WORKLESS_WORKERS_RATIO=50
In this example, it will scale up to a maximum of 10 workers, firing up 1 worker for every 50 jobs on the queue. The minimum will be 0 workers, but you could set it to a higher value if you want.
Copyright (c) 2010 lostboy. Copyright (c) 2016 davidakachaos. Copyright (c) 2017 lostboy && davidakachaos.
See LICENSE for details.
| Back | FazBrowse Home | New Git URL |