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.