[Answered ]-Gunicorn + Django + Virtualenv + init.d service (CentOS)

2👍

Gunicorn’s logs were not the most helpful, out of frustration I tried uwsgi and it immediately displayed the issue:

Traceback (most recent call last):
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
    self.load_middleware()
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
    mw_instance = mw_class()
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__
    for url_pattern in get_resolver(None).url_patterns:
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
    self._urlconf_module = import_module(self.urlconf_name)
  File "/webapps/geonode_django/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "./geonode/urls.py", line 24, in <module>
    from geonode.sitemap import LayerSitemap, MapSitemap
  File "./geonode/sitemap.py", line 21, in <module>
    from geonode.maps.models import Layer, Map
  File "./geonode/maps/models.py", line 35, in <module>
    from geonode.layers.models import Layer
  File "./geonode/layers/models.py", line 33, in <module>
    from geonode.base.models import ResourceBase, ResourceBaseManager, resourcebase_post_save
  File "./geonode/base/models.py", line 28, in <module>
    from geonode.utils import bbox_to_wkt
  File "./geonode/utils.py", line 29, in <module>
    from osgeo import ogr
  File "/webapps/geonode_django/lib/python2.7/site-packages/GDAL-1.11.2-py2.7-linux-x86_64.egg/osgeo/__init__.py", line 21, in <module>
    _gdal = swig_import_helper()
  File "/webapps/geonode_django/lib/python2.7/site-packages/GDAL-1.11.2-py2.7-linux-x86_64.egg/osgeo/__init__.py", line 17, in swig_import_helper
    _mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: /webapps/geonode_django/lib/python2.7/site-packages/GDAL-1.11.2-py2.7-linux-x86_64.egg/osgeo/_gdal.so: undefined symbol: GDALRasterBandGetVirtualMem

Finally!! Ok…so the gunicorn-app.sh needs some variables, so I added the following:

export GDAL_HOME=/opt/gdal-1.11.2
export GDAL_DATA=$GDAL_HOME/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GDAL_HOME/lib
export PATH=$GDAL_HOME/bin:/usr/pgsql-9.3/bin:$PATH

tested it with service gunicorn start… and it works. Well hopefully this helps someone else out.

Leave a comment