Skip to content

Instantly share code, notes, and snippets.

@ethnt
Forked from passcod/Gemfile
Last active December 15, 2015 14:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ethnt/5277124 to your computer and use it in GitHub Desktop.
Save ethnt/5277124 to your computer and use it in GitHub Desktop.
How to use Sidekiq with Padrino.
# config/boot.rb
# ...
# Load our dependencies
require 'rubygems' unless defined?(Gem)
require 'bundler/setup'
Bundler.require(:default, PADRINO_ENV)
# Load worker definitions
require Padrino.root('config', 'workers.rb')
# ...
#!/usr/bin/env rackup
# encoding: utf-8
require File.expand_path("../config/boot.rb", __FILE__)
require 'sidekiq/web'
map('/sidekiq') { run Sidekiq::Web }
run Padrino.application
# ...
gem 'sidekiq'
gem 'slim'
# ...
# workers/hard_worker.rb
class HardWorker
include Sidekiq::Worker
def perform(name, count)
puts 'Doing hard work'
end
end
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)
end
end
# config/workers.rb
Dir[File.expand_path('../../workers/*.rb', __FILE__)].each{|file|require file}
@hooopo
Copy link

hooopo commented Apr 1, 2013

why not worker: bundle exec sidekiq -r ./config/boot.rb?

@moksteven
Copy link

how to run it background

@moksteven
Copy link

how to run it background

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