简体   繁体   中英

Rails background jobs in Dockerized sidekiq duplicates schedule

I use Rails+Sidekiq with whenever gem. Both app and sidekiq are separate docker containers running via docker-compose.

services:
 app:
  build:
    dockerfile: Dockerfile

    ...

 sidekiq:
  build:
  ...

There is one folder app for both services (app and sidekiq). And my problem is that all tasks in schedule.rb run two times (one for app container and another for sidekiq container)

Is there is method to check if it is a sidekiq container not to start scheduled jobs?

(sidekiq starts by command: RAILS_ENV=production bundle exec sidekiq -L /my-app/log/sidekiq_production.log )

Cron jobs don't get created magically from the schedule.rb file. They are only created when you run

whenever --update-crontab

or similar. Remove this command from your script that runs in the Sidekiq container.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM