Running Standalone under WSGI with tilecache_http_server.py

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Running Standalone under WSGI with tilecache_http_server.py

David Yeiser
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache
Reply | Threaded
Open this post in threaded view
|

Re: Running Standalone under WSGI with tilecache_http_server.py

Ivan Mincik-2
On 10/26/2010 07:30 PM, David Yeiser wrote:
> 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?
>

David, You should configure Your Tilecache to run under Apache's
mod_python, see : http://tilecache.org/docs/README.html   .



--
Ivan Mincik, Gista s.r.o.

_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache
Reply | Threaded
Open this post in threaded view
|

RE: Running Standalone under WSGI with tilecache_http_server.py

manel.clos
In reply to this post by David Yeiser
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: [hidden email]
> [mailto:[hidden email]] En nombre de David Yeiser
> Enviado el: martes, 26 de octubre de 2010 19:30
> Para: [hidden email]
> 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
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/tilecache
>
_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache
Reply | Threaded
Open this post in threaded view
|

Re: Running Standalone under WSGI with tilecache_http_server.py

David Yeiser
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, <[hidden email]> <[hidden email]> 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: [hidden email]
>> [mailto:[hidden email]] En nombre de David Yeiser
>> Enviado el: martes, 26 de octubre de 2010 19:30
>> Para: [hidden email]
>> 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
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/tilecache
>>

_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache
Reply | Threaded
Open this post in threaded view
|

RE: Running Standalone under WSGI with tilecache_http_server.py

manel.clos
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 [[hidden email]]
Enviat el: dijous, 28 / octubre / 2010 05:29
Per a: Clos Crespo, Manel
A/c: [hidden email]
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, <[hidden email]> <[hidden email]> 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: [hidden email]
>> [mailto:[hidden email]] En nombre de David Yeiser
>> Enviado el: martes, 26 de octubre de 2010 19:30
>> Para: [hidden email]
>> 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
>> [hidden email]
>> http://lists.osgeo.org/mailman/listinfo/tilecache
>>

_______________________________________________
Tilecache mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/tilecache