Multiple Turbogears apps mod_wsgi

25 views
Skip to first unread message

Juan Antonio Ibáñez

unread,
Jul 16, 2011, 4:54:55 AM7/16/11
to modwsgi
Hello!

I am trying to configure two apps behind same server but I'am
finding following problem:

Both apps are using same template folder, but not always the same.
First executed app seems to set template folder for both apps instead
using its own folder. If I run app1 first (calling one of its
controller methods), app1 and app2 use app1 templates. If app2 runned
first, both app1 and app2 use app2 templates. It is annoyinf for me
and after some days testing configurations I wasn't be able to find a
solution. My apache conf looks as:

------------------------
WSGIPythonHome /usr/local/pythonenv/BASELINE
# TODO: confirm that this line is appropriate for Daemon mode...
WSGIPythonPath /usr/local/pythonenv/ceaf/lib/python2.4/site-packages


# Allow apache to serve static content.
# Your site is configured to mount at /ceaf/ (use --mount to change
this)

Alias /ceaf/images /usr/src/tg2env/ceaf/ceaf/public/images
Alias /ceaf/css /usr/src/tg2env/ceaf/ceaf/public/css
Alias /ceaf/javascript /usr/src/tg2env/ceaf/ceaf/public/javascript

# Choose deamon mode with 10 threads and 3 processes.
# For small to medium website.
WSGIApplicationGroup %{GLOBAL}
WSGIDaemonProcess ceaf threads=10 processes=3
WSGIProcessGroup ceaf
WSGIScriptAlias /ceafv1 /usr/src/tg2env/ceaf/apache/ceaf.wsgi
WSGIScriptAlias /ceafv2 /usr/src/tg2env/ceafv2/apache/ceaf.wsgi
WSGISocketPrefix /var/run/wsgi
------------------------

Any idea where the problem could be?

Regards

Graham Dumpleton

unread,
Jul 16, 2011, 6:42:48 AM7/16/11
to mod...@googlegroups.com
2011/7/16 Juan Antonio Ibáñez <juani...@gmail.com>:

> Hello!
>
>   I am trying to configure two apps behind same server but I'am
> finding following problem:
>
> Both apps are using same template folder, but not always the same.
> First executed app seems to set template folder for both apps instead
> using its own folder. If I run app1 first (calling one of its
> controller methods), app1 and app2 use app1 templates. If app2 runned
> first, both app1 and app2 use app2 templates. It is annoyinf for me
> and after some days testing configurations I wasn't be able to find a
> solution. My apache conf looks as:
>
> ------------------------
> WSGIPythonHome /usr/local/pythonenv/BASELINE
> # TODO: confirm that this line is appropriate for Daemon mode...
> WSGIPythonPath /usr/local/pythonenv/ceaf/lib/python2.4/site-packages

For daemon mode, use python-path option to WSGIDaemonProcess instead.

> # Allow apache to serve static content.
> # Your site is configured to mount at /ceaf/ (use --mount to change
> this)
>
> Alias /ceaf/images /usr/src/tg2env/ceaf/ceaf/public/images
> Alias /ceaf/css /usr/src/tg2env/ceaf/ceaf/public/css
> Alias /ceaf/javascript /usr/src/tg2env/ceaf/ceaf/public/javascript
>
> # Choose deamon mode with 10 threads and 3 processes.
> # For small to medium website.
> WSGIApplicationGroup %{GLOBAL}

You are using a single daemon process but forcing both applications to
run in same interpreter. For TurboGears this likely isn't going to
work.

Use two daemon process groups and delegate each application to different one.

> WSGIDaemonProcess ceaf threads=10 processes=3
> WSGIProcessGroup ceaf
> WSGIScriptAlias /ceafv1 /usr/src/tg2env/ceaf/apache/ceaf.wsgi
> WSGIScriptAlias /ceafv2 /usr/src/tg2env/ceafv2/apache/ceaf.wsgi

WSGIDaemonProcess ceafv1 threads=10 processes=3
WSGIDaemonProcess ceafv2 threads=10 processes=3

WSGIScriptAlias /ceafv1 /usr/src/tg2env/ceaf/apache/ceaf.wsgi

<Location /ceafv1>
WSGIProcessGroup ceafv1
WSGIApplicationGroup %{GLOBAL}
</Location>

WSGIScriptAlias /ceafv2 /usr/src/tg2env/ceafv2/apache/ceaf.wsgi

<Location /ceafv2>
WSGIProcessGroup ceafv2
WSGIApplicationGroup %{GLOBAL}
</Location>

Graham

> WSGISocketPrefix /var/run/wsgi
> ------------------------
>
> Any idea where the problem could be?
>
> Regards
>

> --
> 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.
>
>

Juan Antonio Ibáñez

unread,
Jul 16, 2011, 7:33:45 AM7/16/11
to modwsgi
Do you know if possible to set up / as one of two apps?

Trying to add following config seems not to work well:

----------------------
WSGIScriptAlias / /usr/src/tg2env/ceaf/apache/ceaf.wsgi

<Location />
WSGIProcessGroup ceafv1
WSGIApplicationGroup %{GLOBAL}
</Location>
----------------------





On Jul 16, 12:42 pm, Graham Dumpleton <graham.dumple...@gmail.com>
wrote:
> 2011/7/16 Juan Antonio Ibáñez <juanito1...@gmail.com>:

Graham Dumpleton

unread,
Jul 19, 2011, 12:17:34 AM7/19/11
to mod...@googlegroups.com
Sorry for delay in replying, work sucking up all my free time.

2011/7/16 Juan Antonio Ibáñez <juani...@gmail.com>:

> Do you know if possible to set up / as one of two apps?

Yes you can. You just need to make sure that WSGIScriptAlias for most
deeply nested path is first.

Would also look at qualifying things based on Directory of WSGI script
at that point rather than Location and URL. Using Location with '/' is
actually redundant as that is what VirtualHost level implies.
Directory is more specific anyway.

WSGIDaemonProcess ceafv1 threads=10 processes=3
WSGIDaemonProcess ceafv2 threads=10 processes=3

WSGIScriptAlias /ceafv1 /usr/src/tg2env/ceaf/apache/ceaf.wsgi

<Directory /usr/src/tg2env/ceaf/apache>


WSGIProcessGroup ceafv1
WSGIApplicationGroup %{GLOBAL}

</Directory>

WSGIScriptAlias / /usr/src/tg2env/ceafv2/apache/ceaf.wsgi

<Directory /usr/src/tg2env/ceafv2/apache>


WSGIProcessGroup ceafv2
WSGIApplicationGroup %{GLOBAL}

</Directory>

Graham

Reply all
Reply to author
Forward
0 new messages