Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple opensubmit instances hosted by the same webserver #143

Open
thehappyhippo opened this issue Sep 14, 2016 · 1 comment

Comments

@thehappyhippo
Copy link
Collaborator

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?

@troeger
Copy link
Owner

troeger commented Sep 14, 2016

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.

@troeger troeger removed the question label Sep 14, 2016
@troeger troeger added this to the Far far away milestone Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants