mcuadros / ofelia

A docker job scheduler (aka. crontab for docker)
MIT License
3.09k stars 178 forks source link

How to make it work with Docker-Compose ? #195

Open ghostlexly opened 2 years ago

ghostlexly commented 2 years ago

Hello,

I'am using it today with docker-compose like following :

[job-exec "job-executed-on-running-container"]
schedule = @every 1m
container = message_phpfpm_1
command = php artisan queue:work --tries=3 --max-time=60

message is my project name on docker-compose. How can i call the container with only the container name to be able to use the same file on multiple projects ?

Example of expected ini file:

[job-exec "job-executed-on-running-container"]
schedule = @every 1m
container = phpfpm_1
command = php artisan queue:work --tries=3 --max-time=60
sqlmiles commented 2 years ago

You can use labels configuration instead of ofelia ini config.

maietta commented 2 years ago

It's in the readme.

ghostlexly commented 1 year ago

Can i do the same with the ini ? The labels are good but i don't want to have a long list of labels on my docker compose files

rishid commented 1 year ago

You could probably mount your ini to /etc/ofelia/config.ini inside the container and see if it works

antonellopasella commented 1 year ago

@ghostlexly

I tested mapping "./ofelia/config.ini:/etc/ofelia/config.ini" and it won't works.

Correct path is /etc/ofelia.conf

So the correct mapping would be something like

lincolnaleixo commented 1 year ago

Just for further reference, I was able to make it work that way in the volumes:

Inside folder docker->scheduler it has config.ini

K2ouMais commented 1 year ago

Are you really running the Laravel queue every minute? Why? Is there a reason?

I would understand if you let the scheduler run every minute but not the queue...

Tofandel commented 1 year ago

That readme is missing crucial information

If I want to set global config, how to do it with labels is it

labels:
            ofelia.slack-webhook: 'https://hooks.slack.com/services/...'
            ofelia.slack-only-on-error: 1

Or

labels:
            ofelia.global.slack-webhook: 'https://hooks.slack.com/services/...'
            ofelia.global.slack-only-on-error: 1

What about the no-overlap, is this correct?

            ofelia.job-exec.mailqueue.schedule: "@every 1m"
            ofelia.job-exec.mailqueue.command: "/var/www/html/bin/console swiftmailer:spool:send --mailer=queue --message-limit=30"
            ofelia.job-exec.mailqueue.no-overlap: 1       

Edit:

After trying it seems, the first option is the correct one and the no-overlap should be no-overlap: true

ghostlexly commented 1 year ago

Are you really running the Laravel queue every minute? Why? Is there a reason?

I would understand if you let the scheduler run every minute but not the queue...

Yes, because there have been instances where some of my queues got stuck, and it caused all the other queues to be blocked. So, I added a --max-time parameter to limit it in time and kill any queues that remain stuck.