From cb8f49788862e2558e75ead479a29346bb10fa37 Mon Sep 17 00:00:00 2001 From: Didier Lafforgue Date: Sat, 31 Aug 2024 23:08:00 +0200 Subject: [PATCH] run Sidekiq + declare a Redis server --- config/deploy.yml | 31 +++++++++++++++++++++++++++++-- config/initializers/redis.rb | 7 +++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/config/deploy.yml b/config/deploy.yml index ce5a7df..f6c1077 100644 --- a/config/deploy.yml +++ b/config/deploy.yml @@ -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: @@ -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: @@ -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 diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb index c4558b2..ba5dfab 100644 --- a/config/initializers/redis.rb +++ b/config/initializers/redis.rb @@ -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