6

Let's say that I have a Django app, and I've offloaded environment variable storage to etcd. When I deploy a new server, the app can read from etcd, write the vars into (for example) a Python file that can be conditionally loaded on the app boot. This much is acceptable.

When the configuration changes, however, I have no way of knowing. Afaik, etcd doesn't broadcast changes. Do I need to set up a daemon that polls and then reloads my app on value changes? Should I query etcd whenever I need to use one of these parameters? How do people handle this?

Carson
  • 17,073
  • 19
  • 66
  • 87

2 Answers2

1

You can use ETCD as a settings backend, but in order for Django to pick-up configuration changes during runtime (i.e. without restart/reload), you need to setup a background mechanism to keep reading the settings.

The package django-etcd-settings does it by starting a daemon thread which will then setup a long-polling connection in order to read the keys from ETCD and keep the settings up-to-date.

Ricardo Alves
  • 76
  • 1
  • 6
0

I haven't used CoreOS or Docker but read a lot and think it's very sexy stuff. I guess the solution depends on how you set up your app. If you have the same sort of "touch-reload" support you see in many appservers (uWSGI f.ex.), you can set key_file in /etc/etcd/etcd.conf and make your appserver watch that. This feels a ton heavier than it should be thou. I'm quite sure someone with experience with the platform can come up with something much better.