-
-
Save ethnt/5277124 to your computer and use it in GitHub Desktop.
How to use Sidekiq with Padrino.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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') | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ... | |
gem 'sidekiq' | |
gem 'slim' | |
# ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# workers/hard_worker.rb | |
class HardWorker | |
include Sidekiq::Worker | |
def perform(name, count) | |
puts 'Doing hard work' | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web: bundle exec thin start -p $PORT | |
worker: bundle exec sidekiq -r ./config/workers.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/controllers/test.rb | |
YourApp.controller do | |
get '/test' do | |
HardWorker.perform_async('bob', 5) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/workers.rb | |
Dir[File.expand_path('../../workers/*.rb', __FILE__)].each{|file|require file} |
how to run it background
how to run it background
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why not
worker: bundle exec sidekiq -r ./config/boot.rb
?