简体   繁体   English

TileStache和NGinx

[英]TileStache and NGinx

I am building a mapping application and am using TileStache for tile generation and caching. 我正在构建一个映射应用程序,并使用TileStache进行切片生成和缓存。 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). 我已经在我的rails应用程序中使用NGinx + Passenger,并且试图弄清楚如何从同一Web服务器(NGinx)提供我的rails应用程序和TileStache。 From the NGinx documentation it looks like NGinx need to be re-compiled to add the WSGI module. 从NGinx文档看来,NGinx需要重新编译以添加WSGI模块。 Since I am already using Phusion Passenger module I am not sure how to go about doing this. 由于我已经在使用Phusion乘客模块,因此我不确定该怎么做。 Am I on the right track? 我在正确的轨道上吗? Any suggestions would be appreciated. 任何建议,将不胜感激。

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

We use nginx to serve the tiles out. 我们使用nginx来提供瓷砖。 Works great. 效果很好。

We configure nginx to proxy_pass to the wsgi server. 我们将nginx配置为proxy_pass到wsgi服务器。 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. 然后,我创建了一个python虚拟环境并安装了gunicorn来运行tiletache服务器。 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. 我们通过在supervisor中使用该行来保持gunicorn处于运行状态,因此supervisor负责在gunicorn服务器终止或系统重新启动时启动它。

Tilestache is pretty awesome! Tilestache非常棒!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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