Help us understand the problem. What is going on with this article?

Heroku 上で Rails に非同期処理の sidekiq を導入する

More than 5 years have passed since last update.

基本セットアップ

Gemfile

gem 'sidekiq'

アプリ上では

obj.foo_process

obj.delay.foo_process

という感じで実装すれば遅延処理になる

管理Webviewを設定

管理WebViewにはBasic認証をかける

routes.rb

require 'sidekiq/web'

Sidekiq::Web.use Rack::Auth::Basic do |username, password|
  username == 'basicuser' && password == 'basicpass'
end
mount Sidekiq::Web => '/sidekiq'

Heroku上ではCSSの読み込みが失敗するのを修正

config/envirments/production.rb

config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

開発環境等では非同期にしない

config/initializer/sidekiq.rb

unless Rails.env.production?
  require 'sidekiq/testing/inline'
end

Heroku上でRedisを入れる

heroku addons:add redistogo:nano

ローカル環境

Macでのセットアップ

brew install redis
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away