我正在尝试运行两个wsgi应用程序,一个django和另一个使用相同的服务器。
平铺服务器通过django访问db以查询db。在服务瓷砖的过程中,它对传入的bbox执行转换,并在此过程中命中以下错误。当从python shell手动运行时,转换对特定的bbox多边形没有错误的工作:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/TileStache/__init__.py", line 325, in __call__
mimetype, content = requestHandler(self.config, environ['PATH_INFO'], environ['QUERY_STRING'])
File "/usr/lib/python2.7/dist-packages/TileStache/__init__.py", line 231, in requestHandler
mimetype, content = getTile(layer, coord, extension)
File "/usr/lib/python2.7/dist-packages/TileStache/__init__.py", line 84, in getTile
tile = layer.render(coord, format)
File "/usr/lib/python2.7/dist-packages/TileStache/Core.py", line 295, in render
tile = provider.renderArea(width, height, srs, xmin, ymin, xmax, ymax, coord.zoom)
File "/var/www/tileserver/providers.py", line 59, in renderArea
bbox.transform(METERS_SRID)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/gis/geos/geometry.py", line 520, in transform
g = gdal.OGRGeometry(self.wkb, srid)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/gis/gdal/geometries.py", line 131, in __init__
self.__class__ = GEO_CLASSES[self.geom_type.num]
File "/usr/local/lib/python2.7/dist-packages/django/contrib/gis/gdal/geometries.py", line 245, in geom_type
return OGRGeomType(capi.get_geom_type(self.ptr))
File "/usr/local/lib/python2.7/dist-packages/django/contrib/gis/gdal/geomtype.py", line 43, in __init__
raise OGRException('Invalid OGR Integer Type: %d' % type_input)
OGRException: Invalid OGR Integer Type: 1987180391我想我碰到了GDAL,在django站点举行会议的非线程安全问题。有什么方法可以让我把它配置成工作的吗?
Apache版本:
Apache/2.2.22 (Ubuntu) mod_wsgi/3.3 Python/2.7.3配置
Apache apache2/sites-available/default:
<VirtualHost *:80>
ServerAdmin ironman@localhost
DocumentRoot /var/www/bin
LogLevel warn
WSGIDaemonProcess lbs processes=2 maximum-requests=500 threads=1
WSGIProcessGroup lbs
WSGIScriptAlias / /var/www/bin/apache/django.wsgi
Alias /static /var/www/lbs/static/
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin ironman@localhost
DocumentRoot /var/www/bin
LogLevel warn
WSGIDaemonProcess tilestache processes=1 maximum-requests=500 threads=1
WSGIProcessGroup tilestache
WSGIScriptAlias / /var/www/bin/tileserver/tilestache.wsgi
</VirtualHost>Django版本: 1.4
httpd.conf:
Listen 8080
NameVirtualHost *:8080我添加了一个test.wsgi脚本来确定全局解释器设置是否正确,正如格雷厄姆所提到的,并在这里描述了这一点:
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Sub_解释器_存在_使用
它似乎显示了预期的结果:
年8月14日10:32:01 Apache/2.2.22 (Ubuntu) mod_wsgi /3.3Python/2.7.3配置--恢复正常操作年8月14日10:32:01 mod_wsgi (pid=29891):附加解释器‘。
现在,我已经通过更改db中使用的srs来解决这个问题,这样就没有必要在平铺应用程序中进行转换。我不明白为什么在django应用程序中调用的transform()方法可以工作,但是在tile里根应用程序中却失败了。
#!/usr/bin/python
import os
import time
import sys
import TileStache
current_dir = os.path.abspath(os.path.dirname(__file__))
project_dir = os.path.realpath(os.path.join(current_dir, "..", ".."))
sys.path.append(project_dir)
sys.path.append(current_dir)
os.environ['DJANGO_SETTINGS_MODULE'] = 'bin.settings'
sys.stdout = sys.stderr
# wait for the apache django lbs server to start up,
# --> in order to retrieve the tilestache cfg
time.sleep(2)
tilestache_config_url = "http://127.0.0.1/tilestache/config/"
application = TileStache.WSGITileServer(tilestache_config_url)因此,我确实需要在数据库中使用谷歌(900913)以外的投影。所以我以前的解决办法失败了。
虽然我想解决这个问题,但我决定通过创建一个执行所需转换的django视图来解决这个问题。因此,现在,tilestache通过django应用程序请求数据,而不是内部请求。
发布于 2012-08-01 10:33:09
您的配置已经是单线程的,这就是守护进程的“threads=1”。尝试通过添加以下内容强制使用主解释器:
WSGIApplicationGroup %{GLOBAL}有些Python包在子解释器中不能正常工作。
还要注意,将DocumentRoot设置为源代码所在位置的父目录是错误的做法。不要使用DocumentRoot,让它默认为全局文档根,或者将其设置为指向一个空目录。这样的话,如果你在某一时刻把东西塞进去,你就不会冒着源代码可下载的风险。
https://serverfault.com/questions/413182
复制相似问题