Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Using Sidekiq with multi APIs, but Sidekiq server executed wrong API code

$
0
0

I've built a rails app with docker-compose like below.

For example,API A created job A1, that pushed to redis by Sidekiq Client SA.

And API B created job B1, that pushed to redis by Sidekiq Client SB.

But when these jobs executed, It pointed to application code in only API A.So job B1 was failed because it was executed by API A.

I know that because the uninitialized constant error was raised.

I also used redis-namespace, but it still pointed to wrong API.

Can you help me explain how Sidekiq Server executed jobs.And how it point to the right API that the job belongs to.

Many thanks.

config_redis = {  url: ENV.fetch('REDIS_URL_SIDEKIQ', 'redis://localhost:6379/0'),  namespace: ENV.fetch('REDIS_NAMESPACE_SIDEKIQ', 'super_admin')}Sidekiq.configure_server do |config|  config.redis = config_redisendSidekiq.configure_client do |config|  config.redis = config_redisend

initializer/sidekiq.rb

config_redis = {  url: ENV.fetch('REDIS_URL_SIDEKIQ', 'redis://localhost:6379/0'),  namespace: ENV.fetch('REDIS_NAMESPACE_SIDEKIQ', 'ignite')}Sidekiq.configure_server do |config|  config.redis = config_redisendSidekiq.configure_client do |config|  config.redis = config_redisend

docker-compose.yml

version: "3.9"services:  ccp-ignite-api-gmv: # ----------- IGNITE SERVER    build: ../ccp-ignite-api-gmv/.    entrypoint: ./entrypoint.sh    command: WEB 3001    # command: MIGRATE # Uncomment this if you want to run db:migrate only    ports:      - "3001:3001"    volumes:      - ../ccp-ignite-api-gmv/.:/src    depends_on:      - db      - redis    links:      - db      - redis    tty: true    stdin_open: true    environment:      RAILS_ENV: ${RAILS_ENV}      REDIS_URL_SIDEKIQ: redis://redis:6379/ignite      REDIS_NAMESPACE_SIDEKIQ: ignite  ccp-super-admin-api-gmv: # ----------- SUPER ADMIN API SERVER    build: ../ccp-super-admin-api-gmv/.    entrypoint: ./entrypoint.sh    command: WEB 3005    # command: MIGRATE # Uncomment this if you want to run db:migrate only    ports:      - "3005:3005"    volumes:      - ../ccp-super-admin-api-gmv/.:/src    depends_on:      - db      - redis    links:      - db      - redis    tty: true    stdin_open: true    environment:      RAILS_ENV: ${RAILS_ENV}      REDIS_URL_SIDEKIQ: redis://redis:6379/super_admin      REDIS_NAMESPACE_SIDEKIQ: super_admin  db:    image: mysql:8.0.22    volumes:      - ~/docker/mysql:/var/lib/mysql    command: --default-authentication-plugin=mysql_native_password    environment:      MYSQL_ROOT_PASSWORD: password    ports:      - "3307:3306"  redis:    image: redis:5-alpine    command: redis-server    ports:      - 6379:6379    volumes:      - ~/docker/redis:/data  sidekiq_ignite:    depends_on:      - db      - redis    build: .    command: bundle exec sidekiq    volumes:      - .:/src    environment:      - REDIS_URL_SIDEKIQ=redis://redis:6379/0      - REDIS_NAMESPACE_SIDEKIQ=ignite  sidekiq_super_admin:    depends_on:      - db      - redis    build: .    command: bundle exec sidekiq    volumes:      - .:/src    environment:      - REDIS_URL_SIDEKIQ=redis://redis:6379/0      - REDIS_NAMESPACE_SIDEKIQ=super_admin

Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>