Currently we have 300+ virtual hosts that are using the same Python
process. The connection is done with SCGI. In every VirtualHost we
have:
<VirtualHost "*:80">
ServerName myservername.com
…:
SCGIMount / 127.0.0.1:8080
…
</VirtualHost>
The application can distinguish what site is requested based on the
hostname in the environ. Python process spawns threads when needed.
I wonder how the same setup can be achieved with mod_wsgi? I couldn't
find an example of multiple VirtualHosts using one global Python
process. It seems that you always have to have 1 process per
VirtualHost. I hope I am wrong on this :)
Thanks
Ksenia.
--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To post to this group, send email to mod...@googlegroups.com.
To unsubscribe from this group, send email to modwsgi+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/modwsgi?hl=en.
You can actually put the WSGIProcessGroup outside of the VirtualHost directive.
Thus:
WSGIDaemonProcess Primary threads=15 python-path=/foo/bar/Python
WSGIProcessGroup Primary
WSGIApplicationGroup %{GLOBAL}
<VirtualHost *:80>
ServerName foo1.com
WSGIScriptAlias / /foo/bar/app.wsgi
</VirtualHost>
<VirtualHost *:80>
ServerName foo2.com
WSGIScriptAlias / /foo/bar/app.wsgi
</VirtualHost>
I used '/' with WSGIScriptAlias as you asked for case where mounted at
root of site.
BTW, if the whole VirtualHost goes through to this application and
nothing else is served by them, and every virtual host on server
follows this same recipe, you could do away with the VirtualHost
directives altogether and just put WSGIScriptAlias at global scope.
Graham
On Feb 7, 11:37 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
Thank you for answering. In our situation not all VirtualHost that are
hosted on the server are using the same application. So I guess
WSGIScriptAlias should go inside every VIrtualHost.
On another server we are using mod_wsgi for a different setup (one
virtualhost, one app), with the startup script that looks like:
#!/usr/bin/env python
import os
from paste.deploy import loadapp
from pkg_resources import resource_filename
app_path = os.path.dirname(resource_filename('myapp', ''))
if '/test/' in app_path:
config_file = 'test.ini'
else:
config_file = 'live.ini'
config_path = os.path.join(app_path, config_file)
application = loadapp('config:' + config_path)
But I think if I use this script in the situation with 300
VirtualHost, the same application will be loaded 300 times?! Is it how
it supposed to work?
Thanks again,
Ksenia
So long as you have outside of VirtualHost:
WSGIDaemonProcess Primary threads=15 python-path=/foo/bar/Python
to define the daemon process group. And then:
WSGIScriptAlias / /some/path/app.wsgi
WSGIProcessGroup Primary
WSGIApplicationGroup %{GLOBAL}
inside all VirtualHost's which need it, since not all should be
delegated you are now saying, then there will be only once instance of
application loaded.
This is because WSGIProcessGroup says handle any WSGI applications in
this context in that named process group.
The WSGIApplicationGroup says for the target process, handle any WSGI
applications in this context in the same Python interpreter within
that process.
Thus, so long as all WSGIScriptAlias's refer to the exact same script
file, every virtual host will use that same file and it will only be
loaded once.
Graham