Skip to content

Instantly share code, notes, and snippets.

Created September 20, 2012 05:15
What would you like to do?
Padrino + Sidekiq =
# config/boot.rb
# ...
# Load our dependencies
require 'rubygems' unless defined?(Gem)
require 'bundler/setup'
Bundler.require(:default, PADRINO_ENV)
# Load worker definitions
require File.join(PADRINO_ROOT, 'config', 'workers.rb')
# ...
# ...
gem 'sidekiq'
# ...
# workers/hard_worker.rb
class HardWorker
include Sidekiq::Worker
def perform(name, count)
puts 'Doing hard work'
web: bundle exec thin start -p $PORT
worker: bundle exec sidekiq -r ./config/workers.rb
# app/controllers/test.rb
YourApp.controller do
get '/test' do
HardWorker.perform_async('bob', 5)
# config/workers.rb
Dir[File.expand_path('../../workers/*.rb', __FILE__)].each{|file|require file}
Copy link

Whats the best way to include your models in with the workers?

Copy link

kke commented Nov 5, 2013

@jeregrine in config/workers.rb :

require File.expand_path('../boot.rb', __FILE__)

This way all your workers can do anything that you could do in a padrino console like access models.

Copy link

@kke wouldn't your config/workers be loading up the boot and the boot loading up the workers?

Copy link

allenan commented Sep 1, 2014

In case anyone is trying to to get the sidekiq web interface running, just add the following to

# Load sidekiq web interface
require 'sidekiq/web' 
map('/sidekiq') { run Sidekiq::Web }

require File.expand_path("../config/boot.rb", __FILE__)
run Padrino.application

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment