Giter Site home page Giter Site logo

Comments (7)

davisp avatar davisp commented on May 10, 2024 5

I have to agree wtih jbergstroem that this doesn't belong in core. But I did go ahead and add an example outlining how you can accomplish this with Routes:

http://github.com/benoitc/gunicorn/blob/master/examples/multiapp.py

from gunicorn.

boxed avatar boxed commented on May 10, 2024 1

I spent a lot of time trying to write something like what is suggested in this ticket. First I tried having code that switched virtualenv based on HTTP_HOST. Turns out you really can't deactivate virtualenvs in pure python, so that was a wash.

Then I thought: maybe we can just have a requirement that it's one single virtualenv, so I wrote the code to switch to different WSGI apps based on HTTP_HOST only to discover that you can't run two django apps side by side because django keeps a truly astonishing number of global variables everywhere.

So basically, what I'm saying is it's not all as easy or even feasible as suggested above.

Maybe it's more feasible to do some kind of load balancing thing where workers run in different virtualenvs depending on the app and a central gunicorn master makes sure that the apps that needs more workers get them? Probably not easy or fun to write :(

I'd really like for django to be cleaned up to make this kind of thing possible...

from gunicorn.

jbergstroem avatar jbergstroem commented on May 10, 2024

I think this kind of behavior is best solved by the end user. There's a distinct difference in the way gunicorn works with "multiple sites" compared to a conventional web server.
I would suggest using some simple python library such as werkzeug and make your two apps respond on different routes.

from gunicorn.

sebest avatar sebest commented on May 10, 2024

instead of havint a specific mount point per apps, would it be possible to have an example with virtual host by name?

from gunicorn.

temoto avatar temoto commented on May 10, 2024

Yes, it is totally possible. You can write a trivial mapping of environ['HTTP_HOST'] to apps.

from gunicorn.

sebest avatar sebest commented on May 10, 2024

I think this could be built in gunicorn, what do you think?

from gunicorn.

temoto avatar temoto commented on May 10, 2024

This could be some optional part of gunicorn, like contrib stuff, yes.

I think it would be best as a standalone multiplexor application with separate config. Django/Paste specialization must also go there. Like this:

$ gunicorn wsgi_multi django:project1 myblog.wsgi:wsgi_app anotherapp.foo

Here, gunicorn runs only one application wsgi_multi, other arguments are passed to it via some special API. Or via config or somehow else.

from gunicorn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.