ogcserver and mod_wsgi trouble

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ogcserver and mod_wsgi trouble

Espen Isaksen
Hi!

I am trying to run ogcserver(mapnik2) through mod_wsgi.

First I tried using stand alone wsgi whick worked fine. But using
mod_wsgi I get the following error:

[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34] mod_wsgi
(pid=1640): Target WSGI script '/var/www/wsgi/test.py' cannot be
loaded as Python module.
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34] mod_wsgi
(pid=1640): Exception occurred processing WSGI script
'/var/www/wsgi/test.py'.
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34] Traceback
(most recent call last):
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34]   File
"/var/www/wsgi/test.py", line 7, in <module>
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34]
application = WSGIApp('/var/www/wsgi/ogcserver.conf')
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34]   File
"/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wsgi.py", line 42, in
__init__
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34]     raise
ServerConfigurationError('The factory module could not be loaded.')
[Tue Nov 08 21:12:04 2011] [error] [client 148.122.14.34]
ServerConfigurationError: The factory module could not be loaded.




So I am guessing it does not find my mapfactory.py file. However I
have included that specifically in my wsgi script:

#!/usr/bin/env python

import sys
from mapnik2.ogcserver.wsgi import WSGIApp
sys.path.append('/var/www/wsgi/mapfactory.py')

application = WSGIApp('/var/www/wsgi/ogcserver.conf')
## Removed since running mod_wsgi ##
#if __name__ == '__main__':
#    from wsgiref.simple_server import make_server
#    httpd = make_server('localhost', 8080, application)
#    print "Listening on port 8080...."
#    httpd.serve_forever()




My reference to the mapfactory in ocgserver.conf file is defined like this:
module=/var/www/wsgi/mapfactory




And the mapfactory.py file is like this:
import os
from ogcserver.WMS import BaseWMSFactory
from mapnik2 import Style, Layer, Map, load_map

class WMSFactory(BaseWMSFactory):
    def __init__(self):
        BaseWMSFactory.__init__(self)
        base_path, tail = os.path.split(__file__)
        file_path = os.path.join(base_path, '/var/www/wsgi/kart.xml')
        self.loadXML(file_path)
        self.finalize()
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Dane Springmeyer-5

On Nov 8, 2011, at 1:44 PM, Espen Isaksen wrote:

> import sys
> from mapnik2.ogcserver.wsgi import WSGIApp
> sys.path.append('/var/www/wsgi/mapfactory.py')


You likely need to append the path to the directory that file is in.

So:

sys.path.append('/var/www/wsgi/')

And make sure permissions are good for that and an __init__.py file exists.

Dane
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Espen Isaksen
I changed it to sys.path.append('/var/www/wsgi/') and I added a empty
__init__.py.  But no good.

What kind of permissions do I need. Shouldn't these be ok?
drwxr-xr-x 2 www-data www-data    4096 2011-11-08 21:56 ./
drwxr-xr-x 5 root     root        4096 2011-11-07 09:22 ../
-rw-r--r-- 1 www-data www-data       0 2011-11-08 21:56 __init__.py
-rwxr-xr-- 1 www-data www-data     375 2011-11-08 21:39 mapfactory.py*
-rwxr-xr-- 1 www-data www-data    2239 2011-11-08 21:38 ogcserver.conf*
-rw-r--r-- 1 www-data www-data 2135360 2011-11-07 09:36 skikart.xml
-rwxr-xr-- 1 www-data www-data     166 2011-11-08 21:53 test.py*


Espen



On Tue, Nov 8, 2011 at 10:51 PM, Dane Springmeyer
<[hidden email]> wrote:

>
> On Nov 8, 2011, at 1:44 PM, Espen Isaksen wrote:
>
>> import sys
>> from mapnik2.ogcserver.wsgi import WSGIApp
>> sys.path.append('/var/www/wsgi/mapfactory.py')
>
>
> You likely need to append the path to the directory that file is in.
>
> So:
>
> sys.path.append('/var/www/wsgi/')
>
> And make sure permissions are good for that and an __init__.py file exists.
>
> Dane
>
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Dane Springmeyer-5
In reply to this post by Espen Isaksen

On Nov 8, 2011, at 1:44 PM, Espen Isaksen wrote:

> from mapnik2.ogcserver.wsgi import WSGIApp


Ah ha, I notice you are importing from mapnik2. You should be using the updated OGCServer code which is a standalone package of python files that lives outside of mapnik sources.

You can download it from:

https://github.com/mapnik/OGCServer

Then change you scripts to do:

import ogcserver
# or
from ogcserver import foo

I'm not sure if this will solve your issue, but to investigate more we all should be using the same code.

Dane
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Espen Isaksen
Ok, I though it was OK since running locate ogcserver returns this:
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/WMS.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/WMS.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/__init__.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/__init__.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/cgiserver.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/cgiserver.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/common.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/common.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/configparser.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/configparser.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/exceptions.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/exceptions.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/modserver.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/modserver.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wms111.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wms111.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wms130.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wms130.pyc
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wsgi.py
/usr/lib/pymodules/python2.7/mapnik2/ogcserver/wsgi.pyc


But then again this data might stem from the previous fix you gave me
when I got trouble with m = mapnik.Map(600, 300) and you told me to
copy data from python 2.6 to 2.7:
sudo cp /usr/lib/pyshared/python2.6/mapnik2/*
/usr/lib/pymodules/python2.7/mapnik2/

But I still believed this code was mapnik2 ready since they reside
inside the mapnik2 folder.

I'll try downloading from github and see if that works any better.

Espen



On Tue, Nov 8, 2011 at 11:11 PM, Dane Springmeyer
<[hidden email]> wrote:

>
> On Nov 8, 2011, at 1:44 PM, Espen Isaksen wrote:
>
>> from mapnik2.ogcserver.wsgi import WSGIApp
>
>
> Ah ha, I notice you are importing from mapnik2. You should be using the updated OGCServer code which is a standalone package of python files that lives outside of mapnik sources.
>
> You can download it from:
>
> https://github.com/mapnik/OGCServer
>
> Then change you scripts to do:
>
> import ogcserver
> # or
> from ogcserver import foo
>
> I'm not sure if this will solve your issue, but to investigate more we all should be using the same code.
>
> Dane
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Espen Isaksen
Ok, thanks again Dane. Worked a lot better using the version directly
from Github. For others looking at this later I needed to add WSGIApp
like this:

from ogcserver.wsgi import WSGIApp

Espen




>> Ah ha, I notice you are importing from mapnik2. You should be using the updated OGCServer code which is a standalone package of python files that lives outside of mapnik sources.
>>
>> You can download it from:
>>
>> https://github.com/mapnik/OGCServer
>>
>> Then change you scripts to do:
>>
>> import ogcserver
>> # or
>> from ogcserver import foo
>>
>> I'm not sure if this will solve your issue, but to investigate more we all should be using the same code.
>>
>> Dane
>
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Espen Isaksen
I need to bring this conversation up again. I got OGCServer/Apache
running one time, but later I had problems with Apache not answering
my request at all. So I got sick of it and left it alone. Standalone
wsgi worked fine.

However, I need to get WMS working with Mapnik and tried one more time
on a new Ubuntu machine. Got the latest code for OGCServer on Github,
installed all dependencies and got OGCserver installed.

Now I am pretty much back to the same problem as before. Apache does
not answer my requests, it just hangs in the browser. I tested another
WSGI application and that runs fine.

All I get in my logs is this:
[Tue Dec 06 17:58:58 2011] [info] mod_wsgi (pid=20554): Create
interpreter 'ip-10-228-231-3.eu-west-1.compute.internal|/wms/skikart'.

Anybody familiar with this kind of problem?

Espen



On Tue, Nov 8, 2011 at 11:45 PM, Espen Isaksen <[hidden email]> wrote:

> Ok, thanks again Dane. Worked a lot better using the version directly
> from Github. For others looking at this later I needed to add WSGIApp
> like this:
>
> from ogcserver.wsgi import WSGIApp
>
> Espen
>
>
>
>
>>> Ah ha, I notice you are importing from mapnik2. You should be using the updated OGCServer code which is a standalone package of python files that lives outside of mapnik sources.
>>>
>>> You can download it from:
>>>
>>> https://github.com/mapnik/OGCServer
>>>
>>> Then change you scripts to do:
>>>
>>> import ogcserver
>>> # or
>>> from ogcserver import foo
>>>
>>> I'm not sure if this will solve your issue, but to investigate more we all should be using the same code.
>>>
>>> Dane
>>
_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users
Reply | Threaded
Open this post in threaded view
|

Re: ogcserver and mod_wsgi trouble

Dane Springmeyer-5
Hi Epsen.

We now have a new mailing list at:

http://groups.google.com/group/mapnik

Can you please move this conversation over there :)

But, hint is to try adding this to your wsgi config:

WSGIApplicationGroup %{GLOBAL}

And/or rebuild lxml without threads

./configure --without-threading && make && make install


On Dec 6, 2011, at 10:01 AM, Espen Isaksen wrote:

> I need to bring this conversation up again. I got OGCServer/Apache
> running one time, but later I had problems with Apache not answering
> my request at all. So I got sick of it and left it alone. Standalone
> wsgi worked fine.
>
> However, I need to get WMS working with Mapnik and tried one more time
> on a new Ubuntu machine. Got the latest code for OGCServer on Github,
> installed all dependencies and got OGCserver installed.
>
> Now I am pretty much back to the same problem as before. Apache does
> not answer my requests, it just hangs in the browser. I tested another
> WSGI application and that runs fine.
>
> All I get in my logs is this:
> [Tue Dec 06 17:58:58 2011] [info] mod_wsgi (pid=20554): Create
> interpreter 'ip-10-228-231-3.eu-west-1.compute.internal|/wms/skikart'.
>
> Anybody familiar with this kind of problem?
>
> Espen

_______________________________________________
Mapnik-users mailing list
[hidden email]
https://lists.berlios.de/mailman/listinfo/mapnik-users