Rails Engine to provide Resque support for Thincloud applications.
The Thincloud::Resque engine:
- Manages all of the Resque (and Redis) dependencies for your application
- Initializes the Redis connection and namespace for Resque
- Configures the Resque Front End (resque-web) to use HTTP Basic authentication
- Optionally configures
- Provides a Capistrano recipe to link resque-web assets during deployment
This gem requires Rails 3.2+ and has been tested on the following versions:
This gem has been tested against the following Ruby versions:
Add this line to your application's Gemfile:
Or install it yourself as:
$ gem install thincloud-resque
Thincloud::Resque configuration options are available to customize the engine behavior. Available options and their default values:
# Redis connection details redis_url = "unix:///tmp/redis.sock" redis_namespace = "resque:APP_NAME:RAILS_ENV" redis_driver = "ruby" # make sure to include the gem for your driver # Authenticaiton details used for the Resque Front End web_username = "thincloud-resque" web_password = "thincloud-resque" # Environment(s) where Resque::Mailer should be enabled mailer_environments = [:production]
Several of the options will use environment variables when found.
redis_url -> ENV["REDIS_URL"] web_username -> ENV["RESQUE_WEB_USERNAME"] web_password -> ENV["RESQUE_WEB_PASSWORD"]
Thincloud::Resque module accepts a
configure block that takes the same options listed above. This block can be put into an initializer or inside of a
Thincloud::Resque.configure do |config| config.redis_url = "unix:///tmp/my_redis.sock" config.redis_namespace = "my_redis_namespace" config.redis_driver = "hiredis" # ... end
You can also access the configuration via the Rails configuration object. In fact, the engine uses the Rails config as storage when the block syntax is used. The
Thincloud::Resque::Configuration object is made available under
config.thincloud.resque. You can access this configuration in
config/application.rb or in your
# ... config.thincloud.resque.redis_url = "unix:///tmp/redis.sock" config.thincloud.resque.redis_namespace = "my_config_namespace" config.thincloud.resque.redis_driver = "hiredis" #...
Note: Configuration values take precendence over environment variables.
Resque::Mailer is enabled for environments included in the
mailer_environments array. By default it will be enabled for all mailers in those environments. If you need to selectively enable it for specific mailers you can disable all environments:
config.mailer_environments = 
and, for those mailers that need to background email, add the following line:
Resque has a built-in Front End Sinatra (resque-web) server that provides access to monitor the Resque server's status. To allow access to the Front End through your app you need to mount the engine in
mount Thincloud::Resque::Engine => "/resque"
Call this inside a namespace to create a nested route if needed:
namespace :admin do mount Thincloud::Resque::Engine => "/resque" end
To make resque-web assets available to the released application, add the following line to your
This adds a recipe called
thincloud:resque:link_assets that will run after
deploy:update_code. The recipe links the web assets from the Resque gem directory into your application's public directory.
You'll need Resque workers in order to have any jobs processed. We use
foreman in our deployments to manage these. Simply add the following line to your
worker: bundle exec rake environment resque:work RAILS_ENV=$RAILS_ENV QUEUE=*
This assumes you're running bundler and that you need the environment loaded for these workers. Modify to suit your needs.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create a Pull Request