[Tilecache] Running Standalone under WSGI with tilecache_http_server.py

manel.clos at ajgirona.cat manel.clos at ajgirona.cat
Thu Oct 28 02:24:28 EDT 2010


Hi David,

With the apache configuration as in the example:
WSGIScriptAliasMatch ^/wmsc/([^/]+) /home/umat/dades/wmsc/$1/tilecache.wsgi

The url http://website.com/wmsc/base/ will match and load /home/umat/dades/wmsc/base/tilecache.wsgi
The url http://website.com/wmsc/sports/ will match and load /home/umat/dades/wmsc/sports/tilecache.wsgi

Also, the script I sent, expects a copy of the tilecache package in the same dir:
.../wmsc/base/
  + tilecache.wsgi
  + tilecache.cfg
  + tilecache

if you want to use a globally installed tilecache, comment this line from the script:
sys.path.append(tilecachepath)

I also run Django apps, but in a different process:
WSGIDaemonProcess django_apps ....

Manel.

________________________________________
De: David Yeiser [david at designintellection.com]
Enviat el: dijous, 28 / octubre / 2010 05:29
Per a: Clos Crespo, Manel
A/c: tilecache at lists.osgeo.org
Tema: Re: [Tilecache] Running Standalone under WSGI with        tilecache_http_server.py

Thank you so much for this!

I have created the tilecache.wsgi file and placed the configuration in my vhost file. (It shares a process with my Django install, not sure if that's going to be a problem.)

The missing link now (at least I think) is I am not sure what to call in my OpenLayers code. Before I was calling the URL with port 8080 like so:

layer = new OpenLayers.Layer.TMS("jeffco",
        "http://website.com:8080/", {'layername':'jeffco', 'type':'png'}
);

Any ideas as to what I would call in its place?

Thanks again!
-David

On Oct 27, 2010, at 4:14 AM, <manel.clos at ajgirona.cat> <manel.clos at ajgirona.cat> wrote:

> Hi David,
>
> You can use mod_wsgi on Apache. I'm happily using it with no problems.
>
> I don't know why at this point there is no tilecache.wsgi in the tilecache distribution. I would really like others to comment about it, and also about the script/configuration below.
>
>
> Here is an example mod_wsgi configuration for TileCache
> #----------------
>   # WMSC - TileCache
>    WSGIDaemonProcess coloma-wmsc user=umat group=www-data processes=1 threads=25 display-name=coloma-wmsc inactivity-timeout=600
>    <Directory /home/umat/dades/wmsc/>
>        WSGIProcessGroup coloma-wmsc
>    </Directory>
>
>    WSGIScriptAliasMatch ^/wmsc/([^/]+) /home/umat/dades/wmsc/$1/tilecache.wsgi
> #----------------
>
> This configuration allows multiple instances of TileCache.
>
>
> And here is a simple version of tilecache.wsgi:
> #----------------
> import os, sys
> base_path, tail = os.path.split(__file__)
>
> tilecachepath = base_path
> sys.path.append(tilecachepath)
> from TileCache.Service import Service, wsgiHandler
>
> cfgfiles = (os.path.join(tilecachepath, "tilecache.cfg"))
>
> theService = {}
> def wsgiApp (environ, start_response):
>    global theService
>
>    cfgs = cfgfiles
>
>    if not theService:
>        theService = Service.load(cfgs)
>    return wsgiHandler(environ, start_response, theService)
>
> application = wsgiApp
> #----------------
>
> This version will not catch configuration changes, so once you know what you are doing, you can add this to the script:
>
>    if environ['PATH_INFO'] == "/reload_config":
>        theService = Service.load(cfgs)
>        content = "Config reload OK"
>        start_response('200 OK',[('Content-type','text/plain'),
>                                 ('Pragma','no cache'),
>                                 ('Cache-Control','no-cache, must-revalidate')])
>        return content
>
> Of course, you need to protect access to that url.
>
>
> Hope this helps.
>
>
>> -----Mensaje original-----
>> De: tilecache-bounces at lists.osgeo.org
>> [mailto:tilecache-bounces at lists.osgeo.org] En nombre de David Yeiser
>> Enviado el: martes, 26 de octubre de 2010 19:30
>> Para: tilecache at lists.osgeo.org
>> Asunto: [Tilecache] Running Standalone under WSGI with
>> tilecache_http_server.py
>>
>> Hello,
>>
>> I have a working GIS stack of Mapnik, Tilecache and
>> OpenLayers. I'm new not only to web-based GIS but also
>> Python, Linux, etc.
>>
>> Do I have to run the "python tilecache_http_server.py"
>> command every time I want to use Tilecache?
>>
>> Can I place it in some startup file? I have a server from
>> Slicehost and when I set it up according to their tutorials I
>> added a file that gets run every time the server boots. Could
>> I do something like that with this command? Something like:
>>
>> vi /etc/network/if-pre-up.d/run_tilecache_http_server.py
>>
>> # In run_tilecache_http_server.py there would be some code to
>> start the server
>>
>> # Then I would do something like this:
>> chmod +x /etc/network/if-pre-up.d/run_tilecache_http_server.py
>>
>> Would this work? Does it even make sense? Also, does running
>> the Tilecache server constantly have any negative effects on
>> the overall memory?
>>
>> Thank you!
>> -David_______________________________________________
>> Tilecache mailing list
>> Tilecache at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/tilecache
>>



More information about the Tilecache mailing list