首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在同一个服务器gdal org异常上运行两个wsgi应用程序,带有apache2/modwsgi

在同一个服务器gdal org异常上运行两个wsgi应用程序,带有apache2/modwsgi
EN

Server Fault用户
提问于 2012-08-01 08:12:50
回答 1查看 574关注 0票数 0

我正在尝试运行两个wsgi应用程序,一个django和另一个使用相同的服务器。

平铺服务器通过django访问db以查询db。在服务瓷砖的过程中,它对传入的bbox执行转换,并在此过程中命中以下错误。当从python shell手动运行时,转换对特定的bbox多边形没有错误的工作:

代码语言:javascript
复制
 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

代码语言:javascript
复制
<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:

代码语言:javascript
复制
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里根应用程序中却失败了。

tilestache.wsgi

代码语言:javascript
复制
#!/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)

更新2

因此,我确实需要在数据库中使用谷歌(900913)以外的投影。所以我以前的解决办法失败了。

虽然我想解决这个问题,但我决定通过创建一个执行所需转换的django视图来解决这个问题。因此,现在,tilestache通过django应用程序请求数据,而不是内部请求。

EN

回答 1

Server Fault用户

发布于 2012-08-01 10:33:09

您的配置已经是单线程的,这就是守护进程的“threads=1”。尝试通过添加以下内容强制使用主解释器:

代码语言:javascript
复制
WSGIApplicationGroup %{GLOBAL}

有些Python包在子解释器中不能正常工作。

还要注意,将DocumentRoot设置为源代码所在位置的父目录是错误的做法。不要使用DocumentRoot,让它默认为全局文档根,或者将其设置为指向一个空目录。这样的话,如果你在某一时刻把东西塞进去,你就不会冒着源代码可下载的风险。

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/413182

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档