ajnisbet / opentopodata

Open alternative to the Google Elevation API!
https://www.opentopodata.org
MIT License
323 stars 70 forks source link

add support for hot reloading the config.yaml #100

Closed arnesetzer closed 3 weeks ago

arnesetzer commented 2 months ago

As discussed in #99 a try to enable hot reloading for config (and therefore datasets) without rebuilding the docker image again.

What changed: A watchdog (/app/watcher.py) is etablish via supervisor. On a config.yaml add or change (CAVE: Due to docker limitations it won't happen if the inode changes, see: https://medium.com/@jonsbun/why-need-to-be-careful-when-mounting-single-files-into-a-docker-container-4f929340834) the watchdog is triggerd an kills the uwsgi and flushes memcached.

arnesetzer commented 1 month ago

@ajnisbet Any feedback? 🙈

ajnisbet commented 1 month ago

Thanks for this Arne!

It's no my radar! I've been on holiday the last month and there's a few things I'll need to tweak before merging, here's a quick review (for my later reference):

arnesetzer commented 4 weeks ago

Hi, thanks for the feedback.

* [ ]  Use `subprocess` instead of `os.system`

Done, now using pymemcache to avoid any system manipulation.

  • [ ] Stop and start uwsgi with supervisord instead of killing it

I'm a little bit puzzled how to achieve this. I played around with the supervisorctl but this requires some serious changes in the supervisord configuration (

  • [ ] Add warm cache command

Already done 😄

  • [ ] Watch both config.yaml and example-config.yaml Also done now.
ajnisbet commented 3 weeks ago

Thanks for this work @arnesetzer !

Here's the final working code if you're interested: https://github.com/ajnisbet/opentopodata/commit/d1fc1a733a097b2fbd5dd39336c29a15fb8f0840