Rails Dockerized sidekiq 中的后台作业重复计划

Rails background jobs in Dockerized sidekiq duplicates schedule

每当 gem 时,我都会使用 Rails+Sidekiq。 app 和 sidekiq 都是单独的 docker 容器 运行 通过 docker-compose.

services:
 app:
  build:
    dockerfile: Dockerfile

    ...

 sidekiq:
  build:
  ...

两个服务(app 和 sidekiq)有一个文件夹 app。我的问题是 schedule.rb 运行 中的所有任务两次(一次用于应用程序容器,另一次用于 sidekiq 容器)

是否有方法检查是否是sidekiq容器不启动计划作业?

(sidekiq 通过命令启动:RAILS_ENV=production bundle exec sidekiq -L /my-app/log/sidekiq_production.log

Cron 作业不会从 schedule.rb 文件中神奇地创建。它们仅在您 运行

时创建
whenever --update-crontab

或类似的。从 Sidekiq 容器中 运行 的脚本中删除此命令。