Graham Dumpleton wrote:
>
> On Oct 29, 7:00 pm, Leho Kraav <lkoogliz...@gmail.com> wrote:
>
>> hi all wsgi gurus
>>
>> my goal was to get several isolated trac no-site-packages virtualenvs
>> running under mod_wsgi: 0.11 virtualenv for bunch of live projets,
>> 0.12-dev1 for project dev1 and 0.12-dev2 for project dev2. but i am
>> somewhat unclear regarding ApplicationGroups and ProcessGroups - some
>> setup guides did it one way, some the other. so i also seem to have a
>> mix in my config file. what about having both dev1 and dev2 both in
>> ApplicationGroup %{SERVER}%, should they be in separate AG, or does
>> separate PGs take care of that? perhaps someone could tell me if
>> there's something to be fixed here:
>>
>
> For Trac, due to limitations in Python wrappers for subversion, you
> must use:
>
> WSGIApplicationGroup %{GLOBAL}
>
> So, if using subversion you don't have a choice and if need separation
> must use daemon process groups instead.
>
Speaking of that, I'm not sure if you've seen that someone recently
reported the "instance.__dict__ not accessible in restricted mode" issue
with mod_wsgi 2.5, despite his use of WSGIApplicationGroup %{GLOBAL}
(see http://trac.edgewall.org/ticket/3371#comment:73).
As we don't see the whole configuration he was using, it might be that
the WSGIApplicationGroup directive was wrongly applied. OTOH, he
reported success with a similar setup using mod_python, so it's a bit
troubling. Are you aware of situations where that RuntimeError could
still occur with mod_wsgi 2.5 even when WSGIApplicationGroup %{GLOBAL}
is used?
-- Christian
I looked there, but the only relevant thing I found concerning
multiple instances of Trac was to run all of the instances in one
python interpreter. But to tell the truth I didn't have enough time to
read modwsgi wiki in depth :(
>
>> PS. In the meantime I can provide some details concerning my
>> configuration - what further info do you need?
>
> The Apache configuration related to mod_wsgi would be best starting
> point.
For every project I have this configuration:
WSGIScriptAlias /trac/PROJECT /var/trac/PROJECT/eggs/cgi-bin/trac.wsgi
<Directory /var/trac/PROJECT/htdocs>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
The trac.wsgi files are created by trac-admin <env> deploy <dir>, so
it looks like that:
import os
def application(environ, start_request):
if not 'trac.env_path_parent_dir' in environ:
environ.setdefault('trac.env_path', '/var/trac/PROJECT')
if 'PYTHON_EGG_CACHE' in environ:
os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
elif 'trac.env_path' in environ:
os.environ['PYTHON_EGG_CACHE'] = os.path.join(environ['trac.env_path'],
'.egg-cache')
elif 'trac.env_path_parent_dir' in environ:
os.environ['PYTHON_EGG_CACHE'] =
os.path.join(environ['trac.env_path_parent_dir'],
'.egg-cache')
from trac.web.main import dispatch_request
return dispatch_request(environ, start_request)
This configuration worked rather well in case of one and two projects.
After that I added another 6 projects it started to throw
RuntimeError. It works with similar configuration using mod_python
(and it is faster then configuration based on modwsgi!).
Another thing to notice is that on the same instance of apache there
is one Django application, tomcat5.5 and a few php sites (including
some soap based web services). Half of the trac instances use mysql
and another half use sqlite.
Best regards,
Bartosz
~ Mark C
Sorry, I was trying to set up the Trac as fast as possible, because
other matters were more important at the moment :(.
> It is certainly a bad idea to to run multiple Trac instances in same
> interpreter where not the same code base, different versions of
> plugins, or dependent modules or where need distinct Python egg cache
> directories for projects. Also should be avoided if relying on
> os.environ for setting Trac location.
Only one thing is different among the configurations: a svn
repository. Probably that caused all the problems...
> The Python egg cache is a particular problem in your code as you
> change it on every request and that could screw up badly on a
> multithreaded configuration.
>
> So, that particular auto generated trac.wsgi from trac-admin is
> actually a bit dangerous. Normally one should not be setting Python
> egg cache directory like that. It should be set once only.
Thanks for pointing that out. I will try to adjust my configuration
accordingly. Maybe that info should be posted on
http://trac.edgewall.org/wiki/TracModWSGI too?
Do you think that bad performance could be caused by this egg cache
misconfiguration? As I told before - mod_python seems to work way
faster then mod_wsgi.
Best regards,
Bartosz
Thanks for a really useful, informative answer (and apologies for top posting but that is all I wanted to add).
> -----Original Message-----
> From: trac-...@googlegroups.com
> [mailto:trac-...@googlegroups.com] On Behalf Of Graham Dumpleton
> Sent: 02 November 2009 23:36
> To: Trac Users
> Subject: [Trac] Re: mod_wsgi + multiple projects - works
> well, but unclear about a few things
Thanks for pointing them out. I managed to configure the Trac and
Apache properly now (or at least I think so). Trac is running like a
lighting now with mod_wsgi :-).
Best regards,
Bartosz