Browse Source

Implement workers

rails-credentials-and-worker
Angel Aviel Domaoan 4 years ago committed by Angel Aviel Domaoan
parent
commit
c2f94c34de
  1. 1
      Procfile
  2. 1
      Procfile-worker
  3. 3
      config/routes.rb
  4. 40
      docker-compose.production.yml

1
Procfile

@ -1,2 +1,3 @@
web: rails s web: rails s
webpack: ./bin/webpack-dev-server webpack: ./bin/webpack-dev-server
worker: bundle exec sidekiq -q default,2 -q mailers,1 -q active_storage_analysis,1 -q active_storage_purge,1 -q sunspot_index,1

1
Procfile-worker

@ -0,0 +1 @@
sidekiq: bundle exec sidekiq $SIDEKIQ_QUEUES

3
config/routes.rb

@ -50,4 +50,7 @@ Rails.application.routes.draw do
end end
end end
end end
require "sidekiq/web"
mount Sidekiq::Web => "/sidekiq"
end end

40
docker-compose.production.yml

@ -53,3 +53,43 @@ services:
- RAILS_MASTER_KEY=${WEB_RAILS_MASTER_KEY} - RAILS_MASTER_KEY=${WEB_RAILS_MASTER_KEY}
- RAILS_LOG_TO_STDOUT=true - RAILS_LOG_TO_STDOUT=true
- PORT=80 - PORT=80
worker:
restart: ${WEB_RESTART_MODE}
image: tenshiamd/ruby:2.7-alpine
command: |
bash -c 'bash -s <<EOF
bundle check || bundle install
bundle exec rake db:migrate
bundle exec foreman start -f Procfile-worker
EOF'
volumes_from:
- data
depends_on:
- solr
- redis
environment:
- RAILS_ENV=${WEB_RAILS_ENV}
- RAILS_MASTER_KEY=${WEB_RAILS_MASTER_KEY}
- RAILS_LOG_TO_STDOUT=true
- PORT=80
- SIDEKIQ_QUEUES=-q default,2 -q mailers,1 -q active_storage_analysis,1 -q active_storage_purge,1 -q sunspot_index,1
worker_solr:
restart: ${WEB_RESTART_MODE}
image: tenshiamd/ruby:2.7-alpine
command: |
bash -c 'bash -s <<EOF
bundle check || bundle install
bundle exec rake db:migrate
bundle exec foreman start -f Procfile-worker
EOF'
volumes_from:
- data
depends_on:
- solr
- redis
environment:
- RAILS_ENV=${WEB_RAILS_ENV}
- RAILS_MASTER_KEY=${WEB_RAILS_MASTER_KEY}
- RAILS_LOG_TO_STDOUT=true
- PORT=80
- SIDEKIQ_QUEUES=-q sunspot_index,2

Loading…
Cancel
Save