[mapserver-users] Problem to use mapserver as fcgi with spawn-fcgi and nginx - Process exit after each request

Guillaume Chanaud guillaume.chanaud at connecting-nature.com
Mon Aug 17 14:48:27 EDT 2009


Hello everybody,

I'm trying to setup mapserver running as Fast-CGI with Nginx webserver.
I don't know if my problem comes from mapserver ot spawn-fcgi (or 
nginx), but i'm pretty sure it's mapserver's fault because nginx and 
spawn-fcgi works well with lots of other FCGI.

I use the spawn-fcgi script from lighttpd (here : 
http://redmine.lighttpd.net/projects/spawn-fcgi/news ) with a personnal 
init script
My process are running ok, like it does with php5-cgi for example
My nginx is configure to pass every request to *.cgi to the mapserver 
fcgi instance, so every call to something.cgi works like a charm and 
mapserver process the query and return back what i'm asking for. I did 
the test with the sample data and tutorial and everything is ok.

But :
My fast cgi process process only one request and then die !

Passing things by TCP or socket doesn't change anything. If i spawn 5 
forks, each fork will handle one request and then die, so i can handle 
five request and then mapserver disapear from my system memory.
It works like a charm with php5-cgi (which is fcgi) and the process 
doesn't die. I only change the process to be spawned to mapserver 
instead of php5-cgi, and you know what ? Only one request and die...
I compiled mapserver with the --with-fcgi option, and everything is ok 
for the ./configure

I managed to debug the mapserver fcgi communication with fcgi-debug 
utilities (http://cgit.stbuehler.de/gitosis/fcgi-debug/)
Here is the dump of what i get :
--------------------------------------------------------------------------------------------------------------------------------------- 

vnode004:/usr/local/nginx/conf# spawn-fcgi -s /var/run/mapserver.socket 
-n -u nobody -- /usr/local/bin/fcgi-debug /usr/local/bin/mapserv
new connection 
(0)                                                                                                                       

begin request from webserver (0, 1): role: FCGI_RESPONDER, flags: 
none                                                                  
param from webserver (0, 1): 'QUERY_STRING' = 
''                                                                                         

param from webserver (0, 1): 'REQUEST_METHOD' = 
'GET'                                                                                    

param from webserver (0, 1): 'CONTENT_TYPE' = 
''                                                                                         

param from webserver (0, 1): 'CONTENT_LENGTH' = 
''                                                                                       

param from webserver (0, 1): 'SCRIPT_NAME' = 
'/cgi-bin/mapserv'                                                                          

param from webserver (0, 1): 'REQUEST_URI' = 
'/cgi-bin/mapserv'                                                                          

param from webserver (0, 1): 'DOCUMENT_URI' = 
'/cgi-bin/mapserv'                                                                         

param from webserver (0, 1): 'DOCUMENT_ROOT' = 
'/usr/local/nginx/html'                                                                   

param from webserver (0, 1): 'SERVER_PROTOCOL' = 
'HTTP/1.1'                                                                              

param from webserver (0, 1): 'GATEWAY_INTERFACE' = 
'CGI/1.1'                                                                             

param from webserver (0, 1): 'SERVER_SOFTWARE' = 
'nginx/0.7.61'                                                                          

param from webserver (0, 1): 'REMOTE_ADDR' = 
'90.45.64.64'                                                                               

param from webserver (0, 1): 'REMOTE_PORT' = 
'32938'                                                                                     

param from webserver (0, 1): 'SERVER_ADDR' = 
'192.168.100.4'                                                                             

param from webserver (0, 1): 'SERVER_PORT' = 
'8000'                                                                                      

param from webserver (0, 1): 'SERVER_NAME' = 
'mapserver.connecting-nature.com'                                                           

param from webserver (0, 1): 'REDIRECT_STATUS' = 
'200'                                                                                   

param from webserver (0, 1): 'SCRIPT_FILENAME' = 
'/usr/local/nginx/html/cgi-bin/mapserv'                                                 

param from webserver (0, 1): 'HTTP_HOST' = 
'mapserver.connecting-nature.com:8000'                                                        

param from webserver (0, 1): 'HTTP_USER_AGENT' = 'Mozilla/5.0 (X11; U; 
Linux i686 (x86_64); fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1'
param from webserver (0, 1): 'HTTP_ACCEPT' = 
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'                           

param from webserver (0, 1): 'HTTP_ACCEPT_LANGUAGE' = 
'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'                                              

param from webserver (0, 1): 'HTTP_ACCEPT_ENCODING' = 
'gzip,deflate'                                                                     

param from webserver (0, 1): 'HTTP_ACCEPT_CHARSET' = 
'ISO-8859-1,utf-8;q=0.7,*;q=0.7'                                                    

param from webserver (0, 1): 'HTTP_KEEP_ALIVE' = 
'300'                                                                                   

param from webserver (0, 1): 'HTTP_CONNECTION' = 
'keep-alive'                                                                            

params end from webserver (0, 
1)                                                                                                         

stdin closed from webserver (0, 
1)                                                                                                       

stdout from application (0, 1): Content-type: 
text/html\n                                                                                

stdout from application (0, 1): 
\n                                                                                                       

stdout from application (0, 1): No query information to decode. 
QUERY_STRING is set, but empty.\n                                       
stdout closed from application (0, 
1)                                                                                                    

end request from application (0, 1): applicationStatus: 0, 
protocolStatus: 
FCGI_REQUEST_COMPLETE                                        
connection closed 
(0)                                                                                                                    

** Message: process 5975 exited with status 
256                                                                                          

** Message: exit fcgi-debug
--------------------------------------------------------------------------------------------------------------------------------------------- 


As you can see, after the request i get a "** Message: process 5975 
exited with status 25".
In a php5-cgi debug session, i don't have this and after "connection 
closed (0)" the process is just waiting to handle another request.


What am i missing ? Is this the normal behavior of mapserver as fcgi (So 
we are stuck to apache fcgi process manager ?) ?!

Sorry if this post is too long or messy, i tried to figure things out as 
clear as possible. I can attach my nginx configuration file next time is 
somebody needs it.
(the spawn-fcgi is launched like this :
spawn-fcgi -s /var/run/mapserver.socket -n -u nobody -- 
/usr/local/bin/mapserv
or
spawn-fcgi  -a 127.0.0.1 -p 9000 -u nobody -- /usr/local/bin/fcgi-debug 
/usr/local/bin/mapserv
)
And for those who wants to quick reply "Why don't you just use Apache 
instead of Nginx", i have just lots of reason to become completly insane 
by trying mapserver+nginx (or : i have lots of professional reason to do 
this, even if it make me crazy)


Thanks a lot for those who can help me on this !

Guillaume Chanaud


More information about the mapserver-users mailing list