ofelia
ofelia copied to clipboard
Hot reload of the config
Using inotify or maybe with a signal, allow to reload the configuration without the requirement of restart the process
HUP is the standar Unix signal for "reload config".
BTW this is already implemented, but not very tested, so this is the reason because I didn't closed the issue
@mcuadros how do i go about testing this?
BTW this is already implemented
@mcuadros Can you please describe how to test hot reloading?
Has this been in testing since 2017 ? Or was the feature abandoned ? Reloading config would be a huge advantage in order to not lose job state (such as jobs with @every scheduling not all restarting from scratch when you restart the container).
This is working fine for me when called manually with docker exec -it ofelia killall -HUP ofelia. But I had problems when called by a exec job:
version: "2.4"
services:
ofelia:
container_name: ofelia
image: mcuadros/ofelia
restart: always
command: daemon --docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
ofelia.enabled: "true"
ofelia.job-exec.reload_config.schedule: "@daily"
ofelia.job-exec.reload_config.command: killall -HUP ofelia
2021-12-16T07:41:50.044Z common.go:125 ▶ NOTICE [Job "reload_config" (48efe0168ed5)] Started - killall -HUP ofelia
2021-12-16T07:41:50.409Z common.go:121 ▶ ERROR [Job "reload_config" (48efe0168ed5)] Finished in "17.295737ms", failed: true, skipped: false, error: error creating exec: No such container:
What is wrong here?
Update: it's working when adding ofelia.job-exec.reload_config.container: ofelia but never needed this before for such configs.
The above idea using killall actually kills the primary process in the container and therefore stops the container. The only reason it's restarting and reloading config is the "restart: always" setting. So, this is still reloading the config through a restart. Any progress on a proper way to reload the config?
At the end I decided to run a separate container for each job.
For other's having the same need: The issue of ofelia not detecting changes to newly created or created docker containers is the one thing that bothers me as well. I've tried to use @rdelcorro's fork, but that has some issues picking up tasks if ofelia is started after other containers. I've ended up using the solution from @escoand but with "job-local" instead of "job-exec"
labels:
ofelia.job-local.ofelia-reloadConfig.schedule: "50 59 * * * *"
ofelia.job-local.ofelia-reloadConfig.command: killall -HUP ofelia
I've decided to restart ofelia on minute 59 of every hour because I don't have any tasks running at this time. Only issue is, if you decide to use "@hourly" etc. on any task, the next run will be exactly when ofelia restarts and won't work. But tbh, I don't like those time schedules anyways, I like to define when exactly my tasks should run ;)
Greets.
I myself switched to this fork because of various problems with the killall: https://github.com/BTLzdravtech/ofelia.git
I myself switched to this fork because of various problems with the
killall: https://github.com/BTLzdravtech/ofelia.git
Thank you, I'll give it a try. Unfortunately, I can find no documentation on changes.
Huh, I'm also wondering why I did so. It seems he is working on his branch and force-pushed an older version.
@BTLzdravtech your fork included the docker reload patches but they're gone. Would you mind to re-publish it?