opensubmit
opensubmit copied to clipboard
Support for multiple opensubmit instances hosted by the same webserver
I looked for solution to distinguish 2 opensubmit instances (separate urls) to select the right configuration ini file in settings.py. A possible solution in combination with wsgi is to have separate wsgi.py and set an environment variable, which can be read in settings.py.
wsgi.py:
os.environ["DJANGO_SETTINGS_MODULE"]= "opensubmit.settings"
os.environ["SUBMIT_INI"]="/etc/opensubmit/settings_1.ini" # use separate configfiles in the wsgi.py
settings.py:
instance=os.environ.get("SUBMIT_INI",'/etc/opensubmit/settings.ini') #multi instance setup
config_info = (
(instance, True), # Linux production system
What I thought was a webserver variable (SetEnv in apache2) identifying the instance and that can be read in settings.py, but that seems not be portable between webservers. Is there a more elegant solution? Proposals?
Your idea sounds very reasonable to me.
All web applications struggle with that issue. There are tons of solutions - config data in the database, config data in the web folders, config data based on environment variables, config data based on files linked by environment variables. All approaches have their pros and cons.
The main issue is to pass the environment variable through WSGI. The best solution I could find is this one:
http://stackoverflow.com/questions/25489009/set-up-the-django-settings-file-via-django-settings-module-environment-variable/25496668#25496668
You basically abuse the WSGIProcessGroup identifier to find the name of the right config file. They could still all live in /etc/opensubmit/ with that approach.