ofelia icon indicating copy to clipboard operation
ofelia copied to clipboard

Hot reload of the config

Open mcuadros opened this issue 10 years ago • 13 comments

Using inotify or maybe with a signal, allow to reload the configuration without the requirement of restart the process

mcuadros avatar Oct 06 '15 02:10 mcuadros

HUP is the standar Unix signal for "reload config".

juanjux avatar Jan 14 '17 14:01 juanjux

BTW this is already implemented, but not very tested, so this is the reason because I didn't closed the issue

mcuadros avatar Jan 15 '17 17:01 mcuadros

@mcuadros how do i go about testing this?

timgriffiths avatar Jun 21 '17 13:06 timgriffiths

BTW this is already implemented

@mcuadros Can you please describe how to test hot reloading?

mbtamuli avatar Oct 23 '18 03:10 mbtamuli

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).

Gaibhne avatar Aug 04 '20 09:08 Gaibhne

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.

escoand avatar Dec 16 '21 07:12 escoand

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?

nhe050 avatar May 16 '22 06:05 nhe050

At the end I decided to run a separate container for each job.

wintercounter avatar Jul 22 '22 18:07 wintercounter

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.

benedictschmieder avatar Nov 07 '22 09:11 benedictschmieder

I myself switched to this fork because of various problems with the killall: https://github.com/BTLzdravtech/ofelia.git

escoand avatar Nov 07 '22 11:11 escoand

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.

benedictschmieder avatar Nov 07 '22 11:11 benedictschmieder

Huh, I'm also wondering why I did so. It seems he is working on his branch and force-pushed an older version.

escoand avatar Nov 07 '22 11:11 escoand

@BTLzdravtech your fork included the docker reload patches but they're gone. Would you mind to re-publish it?

escoand avatar Nov 07 '22 18:11 escoand