简体   繁体   中英

TileStache and NGinx

I am building a mapping application and am using TileStache for tile generation and caching. I am already using NGinx+Passenger for my rails app and am trying to figure out how to serve both my rails app and TileStache from the same web server (NGinx). From the NGinx documentation it looks like NGinx need to be re-compiled to add the WSGI module. Since I am already using Phusion Passenger module I am not sure how to go about doing this. Am I on the right track? Any suggestions would be appreciated.

由于对于此特定项目,数据是静态的,因此我决定使用TileStache播种/预热缓存,并将切片作为静态资产进行服务器处理。

We use nginx to serve the tiles out. Works great.

We configure nginx to proxy_pass to the wsgi server. In the sites-enabled file:

 location / {
     proxy_pass          http://127.0.0.1:XXXXSOMEPORTXXXX;
     proxy_set_header    Host       $host;
     proxy_set_header    X-Real-IP  $remote_addr;
     proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_connect_timeout 900s;
     proxy_read_timeout 900s;
 }

I gave it a long timeout so the client can wait awhile, you might want less.

I then created a python virtual environment and installed gunicorn to run the tilestache server. It can be run with a command like this:

XXXXPATHTOVIRTUALENVXXXX/bin/gunicorn --max-requests 1  --timeout 900 --graceful-timeout 890 -b 127.0.0.1:XXXXSOMEPORTXXXX -w 20 "TileStache:WSGITileServer('XXXXPATHTOTILESCONFIGXXXX/tiles.conf')"

We keep gunicorn running by using that line in supervisord so supervisor is responsible for firing up the gunicorn server when it terminates or the system restarts.

Tilestache is pretty awesome!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM