Comments (7)
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.
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.
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.
instead of havint a specific mount point per apps, would it be possible to have an example with virtual host by name?
from gunicorn.
Yes, it is totally possible. You can write a trivial mapping of environ['HTTP_HOST'] to apps.
from gunicorn.
I think this could be built in gunicorn, what do you think?
from gunicorn.
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)
- Gunicorn server startup failure messes up signal handling and affects further calls to `subprocess.run` HOT 1
- Rare bug - gunicorn worker stuck during TCP socket sendall HOT 2
- Getting 404 while using Gunicorn with NginX in Django deployment HOT 5
- Choosing a number of workers in a distributed system scenario HOT 1
- Security mailbox seems broken
- Does gunicorn want to support WSGI+ ?
- Is gunicorn project still alive? HOT 4
- The redundancy of argument parser (possibly its removal) in the class gunicorn.app.wsgiapp.WSGIApplication from file wsgiapp.py HOT 1
- Clarification sought on some aspects of the source code HOT 4
- proc_name not being assigned (Linux) HOT 2
- Inaccessible home dir causes SSL to fallback HOT 2
- Gunicorn ignores signals
- How to route traffic when using gunicorn? HOT 1
- Conda Env Module not found
- --limit-request-line check default to MAX_REQUEST_LINE HOT 2
- Gunicorn + Flask App RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method
- use --preload but workers did not share memory from master process HOT 1
- [Question] TLS certificate rotation
- gunicorn not starting automatically !! HOT 6
- Any updates on a release to resolve CVE-2024-1135? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gunicorn.