Like Sidekiq's standard worker, but will exit when the queue runs dry.
Add this line to your application's Gemfile:
gem 'done_when_queue_empty_worker_for_sidekiq', github: 'samsm/done_when_queue_empty_worker_for_sidekiq' run done_when_queue_empty_worker
I wrote this quick hack to reduce cost/compexity of Heroku workers in non-production environments.
It costs ~$35 to run an on-all-the-time worker on Heroku. However, my experience has been that there is less than $1 worth of work to be done in a staging or acceptance environment.
Add done_when_queue_empty_worker_for_sidekiq to your Procfile. In environments where you do not need an always-on worker, set this done when empty worker to run every 10 minutes. Most the time it will immediately exit, charging you practically nothing.
Or just fire it up to help out when a queue is running high.
- Fork it ( https://github.com/samsm/done_when_queue_empty_worker_for_sidekiq/fork )
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a new Pull Request