Skip to content
This repository was archived by the owner on Jul 3, 2020. It is now read-only.

Commit a288f71

Browse files
committed
Add sidekiq service
1 parent a76fb5c commit a288f71

File tree

5 files changed

+44
-11
lines changed

5 files changed

+44
-11
lines changed

backend/Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ gem 'puma', '~> 3.7'
1111

1212
gem 'devise_token_auth'
1313
gem 'omniauth'
14-
gem 'hashie', '~> 3.5.7'
1514
gem 'redis'
15+
gem 'sidekiq'
16+
gem 'connection_pool'
1617

1718
group :development, :test do
1819
gem 'pry'

backend/Gemfile.lock

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ GEM
4343
builder (3.2.3)
4444
coderay (1.1.2)
4545
concurrent-ruby (1.0.5)
46+
connection_pool (2.2.1)
4647
crass (1.0.3)
4748
devise (4.3.0)
4849
bcrypt (~> 3.0)
@@ -89,6 +90,8 @@ GEM
8990
pry (>= 0.10.4)
9091
puma (3.11.2)
9192
rack (2.0.4)
93+
rack-protection (2.0.1)
94+
rack
9295
rack-test (0.8.3)
9396
rack (>= 1.0, < 3)
9497
rails (5.1.5)
@@ -136,6 +139,11 @@ GEM
136139
rspec-support (~> 3.7.0)
137140
rspec-support (3.7.1)
138141
ruby_dep (1.5.0)
142+
sidekiq (5.1.1)
143+
concurrent-ruby (~> 1.0)
144+
connection_pool (~> 2.2, >= 2.2.0)
145+
rack-protection (>= 1.5.0)
146+
redis (>= 3.3.5, < 5)
139147
spring (2.0.2)
140148
activesupport (>= 4.2)
141149
spring-watcher-listen (2.0.1)
@@ -162,8 +170,8 @@ PLATFORMS
162170
ruby
163171

164172
DEPENDENCIES
173+
connection_pool
165174
devise_token_auth
166-
hashie (~> 3.5.7)
167175
listen (>= 3.0.5, < 3.2)
168176
omniauth
169177
pg (>= 0.18, < 2.0)
@@ -173,6 +181,7 @@ DEPENDENCIES
173181
rails (~> 5.1.5)
174182
redis
175183
rspec
184+
sidekiq
176185
spring
177186
spring-watcher-listen (~> 2.0.0)
178187
tzinfo-data

backend/config/application.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
require "action_view/railtie"
1111
require "action_cable/engine"
1212
# require "sprockets/railtie"
13-
# require "rails/test_unit/railtie"
1413

1514
# Require the gems listed in Gemfile, including any gems
1615
# you've limited to :test, :development, or :production.
@@ -21,6 +20,8 @@ class Application < Rails::Application
2120
# Initialize configuration defaults for originally generated Rails version.
2221
config.load_defaults 5.1
2322

23+
config.active_job.queue_adapter = :sidekiq
24+
2425
# Settings in config/environments/* take precedence over those specified here.
2526
# Application configuration should go into files in config/initializers
2627
# -- all .rb files in that directory are automatically loaded.

backend/config/routes.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
require 'sidekiq/web'
2+
13
Rails.application.routes.draw do
24
root to: 'api/status#index'
35

46
namespace :api do
57
mount_devise_token_auth_for 'User', at: 'auth'
68

9+
namespace :jobs do
10+
mount Sidekiq::Web => '/ui'
11+
end
12+
713
get '/', to: 'status#index'
814
end
915
end

docker-compose.yml

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
version: '2'
22

33
services:
4+
redis:
5+
image: redis
6+
volumes:
7+
- ./backend/tmp/redis:/data
8+
ports:
9+
- 6379:6379
10+
worker:
11+
build: backend
12+
command: bundle exec sidekiq
13+
environment:
14+
REDIS_URL: redis://redis:6379/0
15+
depends_on:
16+
- db
17+
- redis
418
nginx:
519
image: bitnami/nginx:1.10.2-r1
620
volumes:
@@ -9,23 +23,28 @@ services:
923
- backend
1024
- frontend
1125
environment:
12-
- VIRTUAL_HOST=yourproject.docker
13-
- VIRTUAL_PORT=8080
26+
VIRTUAL_HOST: yourproject.docker
27+
VIRTUAL_PORT: 8080
1428
ports:
1529
- 8080:8080
1630
db:
1731
image: postgres:latest
1832
volumes:
1933
- /backend/tmp/db:/var/lib/postgresql/data
2034
environment:
21-
- POSTGRES_USER=postgres
22-
- POSTGRES_PASSWORD=secret
35+
POSTGRES_USER: postgres
36+
POSTGRES_PASSWORD: secret
2337
backend:
2438
build: backend
2539
depends_on:
2640
- db
41+
- redis
42+
- worker
2743
volumes:
2844
- ./backend:/usr/src/backend-app
45+
environment:
46+
REDIS_URL: redis://redis:6379/0
47+
SIDEKIQ_REDIS_URL: redis://redis:6379/1
2948
frontend:
3049
build:
3150
context: ./frontend/
@@ -36,7 +55,4 @@ services:
3655
- ./frontend/:/usr/src/frontend-app
3756
- ./frontend/node_modules:/usr/src/frontend-app/node_modules
3857
ports:
39-
- "35729:35729"
40-
environment:
41-
- REACT_APP_API_URL=http://localhost:3000
42-
- CHOKIDAR_USEPOLLING=true
58+
- "35729:35729"

0 commit comments

Comments
 (0)