Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using etcd to manage Django settings

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?

like image 886
Carson Avatar asked Aug 19 '14 14:08

Carson


1 Answers

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.

like image 184
Ricardo Alves Avatar answered Oct 23 '22 17:10

Ricardo Alves