Skip to content

Commit

Permalink
run Sidekiq + declare a Redis server
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Aug 31, 2024
1 parent 15935b6 commit cb8f497
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
31 changes: 29 additions & 2 deletions config/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,23 @@ service: staging-app
image: locomotivecms/staging-app

# Deploy to these servers.
servers:
- 174.138.51.62
servers:
web:
hosts:
- 174.138.51.62
labels:
traefik.http.routers.my_awesome_app.entrypoints: websecure
traefik.http.routers.my_awesome_app.rule: Host(`beta.locomotive.works`) || Host(`demo.locomotivecms.com`) || Host(`recaptcha.nocoffee.fr`)
traefik.http.routers.my_awesome_app.tls.certresolver: letsencrypt
options:
network: "private"

job:
hosts:
- 174.138.51.62
cmd: bundle exec sidekiq -e production -t 25
options:
network: "private"

# Credentials for your image host.
registry:
Expand All @@ -15,6 +30,17 @@ registry:
password:
- DOCKER_REGISTRY_TOKEN

accessories:
redis:
image: redis:7.0
roles:
- web
- job
volumes:
- /var/lib/redis:/data
options:
network: "private"

# Inject ENV variables into containers (secrets come from .env).
# Remember to run `kamal env push` after making changes!
env:
Expand All @@ -27,6 +53,7 @@ env:
RAILS_ENV: production
RAILS_LOG_TO_STDOUT: enabled
RAILS_SERVE_STATIC_FILES: enabled
REDIS_URL: "redis://staging-app-redis:6379/0"
secret:
- RAILS_MASTER_KEY
- SECRET_KEY_BASE
Expand Down
7 changes: 7 additions & 0 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require 'hiredis'
require 'active_support/cache/redis_cache_store'

begin
redis = Redis.new
pp redis.ping
rescue Exception => e
pp "🚨🚨🚨 #{e.message}"
end

# UPDATE (03/02/2023): not required apparently
# My attempt to fix this inconsistent behavior of HiRedis. The issue is described here:
# https://github.com/redis/hiredis-rb/issues/40
Expand Down

0 comments on commit cb8f497

Please sign in to comment.