Using etcd to manage Django settings
Asked Answered
S

2

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?

Szeged answered 19/8, 2014 at 14:13 Comment(0)
Q
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.

Quote answered 27/6, 2018 at 8:37 Comment(0)
N
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.

Nonpayment answered 28/10, 2014 at 15:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.