2009/3/23
ben.d...@googlemail.com <
ben.d...@googlemail.com>:
>
> Hi Graham,
> One final question. The scripts above required a wsgi file per site.
> I've rewritten it to direct all the sites through a single .wsgi file,
> then used thin wrapper round the application to send it on its way to
> the correct (django) settings based on environs settings. This seems
> to work pretty well, even though it removes the 'touch' reloading
> method.
>
> But I'm concerned whether this script might be setting itself up for a
> fall due to the way modwsgi is handling apache processes in embedded
> mode since a new application group is being defined for each site
> (which it needs to be since each site may be operating in different
> virtualenv)? Isn't this what the daemon process mode is for? I'm
> thinking of this line from the Configuration Guidelines:
>
> 'Where multiple applications, potentially owned by different users,
> need to be run, 'daemon' mode of mod_wsgi should instead be used."
Using daemon mode would certainly be preferable, but as you already
know, one can do it with different application groups (sub
interpreters) within same process.
> If that's true can the daemon process name be defined dynamically? Or
> does this method necessarily require embedded mode?
You can switch it around.
WSGIProcessGroup %{ENV:subdomain}
WSGIApplicationGroup %{GLOBAL}
The only problem with this is that you then need to statically define
a WSGIDaemonProcess directive for each sub domain, which is contrary
to what your original aims were from memory. That is, to not have to
change the Apache configuration to add a new site.
One of the main aims in mod_wsgi 4.0, see:
http://blog.dscpl.com.au/2009/03/future-roadmap-for-modwsgi.html
is to provide support for dynamic creation of daemon process groups
through defining only a single parameterisable template.
So, you will not get exactly what you wish until then.
The closest thing you will get for now is to define in advance
WSGIDaemonProcess directives for a pool of daemon process groups. This
would be given generic names. You would then use a RewriteMap to
dynamically assign stuff for a sub domain to one of the daemon process
groups in the pool of daemon process groups.
WSGIDaemonProcess site-1
WSGIDaemonProcess site-2
WSGIDaemonProcess site-3
WSGIDaemonProcess site-4
WSGIDaemonProcess site-5
WSGIDaemonProcess site-6
WSGIDaemonProcess site-7
RewriteEngine On
RewriteMap wsgiprocmap txt:/etc/httpd/wsgiprocmap.txt
RewriteRule . - [E=PROCESS_GROUP:${wsgiprocmap:%{ENV:subdomain}}]
WSGIProcessGroup %{ENV:PROCESS_GROUP}
Then when you add a new site, as well as creating directories in file
system, add an entry in the rewrite map, such as:
foobar.com site-1
Does mean you have to do some manual stuff in Apache configuration,
but you can at least preconfigure a whole bunch and then map then with
the write map file without having to restart Apache, as Apache will
automatically reread the rewrite map file when it changes.
Have I captured the intent of what you are trying to do?
Graham