File: tiles_app.py

package info (click to toggle)
tilelite 0.1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 648 kB
  • ctags: 95
  • sloc: python: 528; xml: 79; makefile: 10
file content (59 lines) | stat: -rwxr-xr-x 2,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
To setup TileLite on a production server using Apache and ModWSGI
create a virtualhost or otherwise insert the WSGI configuration into
your Apache configuration like so:

    WSGIScriptAlias /<url> /path/to/this/tiles_app.py
    WSGIDaemonProcess <process name> user=<user> group=<group> processes=10 threads=1
    WSGIProcessGroup <process name>

 * 'tiles_app.py' is the name of the simple python script below that associates the 
   tilelite.Server instance with a Mapnik xml file. It can be named anything you like
   but should end with either a '.wsgi' or '.py' extension.
    
 * <url> can be either be '/' (to mount the script at http://yourserver.com/) or it can be 
   a path such as '/tiles' to mount the server at http://yourserver.com/tiles

 * <process name> can be any unique name like 'tileliteserver'

 * <user> and <group> should be a unix user that has permissions to the 'tiles_app.py'

 * Note: this is a multiprocess (not threaded) server so you *can* set 'processes' >= 1
   but threads *must be* == 1, otherwise this server will not work within Apache.

An example setup would be:

    ## TileLite sample setup ##
    WSGIScriptAlias /tiles /home/mapnik/projects/tilelite/tiles_app.py
    WSGIDaemonProcess tileliteserver user=www-data group=www-data processes=10 threads=1
    WSGIProcessGroup tileliteserver

Next, edit the script code below and place it where the WSGIScriptAlias path points to.

Then test your apache configuration and restart. On debian linux this might look like:

    $ sudo apache2ctl configtest
    $ /etc/init.d/apache restart

Then go to:

    http://yourserver.com/tiles/
    
"""

def append_local_dir():
    import os,sys
    local_dir = os.path.dirname(__file__)
    sys.path.append(local_dir)

# put local tilelite on PYTHONPATH
# only needed if you have not already installed in site-packages
#append_local_dir()

from tilelite import Server

# point at your mapnik xml or cascadenik mml...
mapfile = '/home/mapnik/osm.xml'
config = None
# note: this variable must be called 'application'
application = Server(mapfile,config)