Ticket #3099 (closed defect: fixed)
Mapserver not working in fcgi mode and external spawning manager
| Reported by: | gehasia | Owned by: | sdlime |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | MapServer FastCGI | Version: | svn-trunk (development) |
| Severity: | normal | Keywords: | |
| Cc: | warmerdam, dmorissette |
Description
Hi,
i did some test with mapserver as fcgi + spawn-fcgi + nginx.
The problem is that in the case mapserver generates an error (invalid mapfile syntax or invalid mapfile path for example) the external fcgi process kill himself ! It should just send the error and keep running...
Here is my test case and result :
Nginx + spawn-fcgi + mapserver :
Calling valid mapfile like this :
http://localhost/cgi-bin/mapserv.fcgi?map=/var/mapfile.map&mod=map
= OK - Process Remains
Calling invalid mapfile like this :
http://localhost/cgi-bin/mapserv.fcgi?map=/var/mpfile.map&mod=map
(in this case mpfile.map does not exists) = NO OK = Throw an error but then terminate the fcgi process !! So no more fcgi process running and all others queries, valid or invalid, won't work !
Apache + fcgid (or fastcgi) + mapserver
= OK for both case, but this is the apache fcgi manager which relaunch the fcgi process as i can see. This is the installation documented everywhere
Apache + spawn-fcgi + mapserver (fcgi is called as an external process, communication done via tcp or socket)
Same results than with Nginx in first case. Valid url = OK, invalid mapfile or any other error (error in mapfile syntax ) = fcgi process get killed
So i did some test with another well known fast-cgi aka PHP ...
Nginx + spawn-fcgi + php5-cgi
Valid or invalid php file (ie : throw errors) keep the process running, so normal behavior
Apache + spawn-fcgi + php5-cgi
Valid or invalid php file (ie : throw errors) keep the process running, so normal behavior
The php5 cgi has a normal comportment, it throws error and keep running. The mapserver throws error and kill himself.
I did some debug with fcgi-debug tool and here is the result if we send an invalid command to the mapserver cgi :
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, there is a
Message: process 5975 exited with status 256
but the fcgi did send the html error message correctly (and after that, died)
in a php-cgi session, you have the message but the process does not exit after (it just continues to listen).
I don't think this is a normal behavior, as with my different test case i can conclude it's not the nginx (because it does the same with apache) or spawn-fcgi (because it runs well php5-cgi -with nginx and apache-) fault. Why mapserver kill himself when it throws an error ?? Is it not the mapserver fcgi role to keep himself running and spawn fork or keep them clean ?
I can add more test case or debug info if needed ! (and i hope i do not make a mistake on who, in the fcgi world, has to keep up running and spawning process)
This affect every version i tried (Debian binary, stable source, trunk source)

