Project

General

Profile

[Solved] No response from an externally spawned fastcgi server.

Added by iamrhari over 4 years ago

My REST service consists of :

lighttpd (websever)
flup (fastcgi/wsgi gateway)
bottle (rest framework)

The intent is to externally spawn the fastcgi gateway and have lighttpd communicate with it over a TCP/IP socket.

While the external spawning seems to have worked, there is NO Response for the request.
Please note that the service works when lighty is configured with a unix socket instead.

Please help me understand what is incorrect in my configuration.

---------------------------------------------
lighty config:
---------------------------------------------
Following is the lighttpd configuration to enable fastcgi server:
fastcgi.server = (
".py" => (
"rest-fcgi-wrapper" => (
"host" => "127.0.0.1",
"port" => "30099",
"check-local" => "disable",
)
)
)
---------------------------------------------
spawn_fcgi helper script:
---------------------------------------------
$ cat spawn-rest.sh
SPAWNFCGI="/usr/bin/spawn-fcgi"
FCGIPROGRAM="/opt/local/components/rest/rest_fcgi.py"
FCGIPORT="30099"
FCGI_WEB_SERVER_ADDRS="127.0.0.1"
USERID=rest
GROUPID=rest
exec $SPAWNFCGI -a $FCGI_WEB_SERVER_ADDRS -p $FCGIPORT -f $FCGIPROGRAM -u $USERID -g $GROUPID

---------------------------------------------
Flup fcgi (rest_fcgi.py):
---------------------------------------------
import os
from flup.server.fcgi import WSGIServer
from restserver import app

if name == "__main__":
os.chdir(os.path.dirname(os.path.abspath(file)))
WSGIServer(app).run()

---------------------------------------------
Last line in lighty error log:
---------------------------------------------
2016-11-15 10:20:14: (mod_fastcgi.c.3041) got proc: pid: 0 socket: tcp:127.0.0.1:30099 load: 1

---------------------------------------------
netstat entries after the request is made:
---------------------------------------------
$ netstat -na | grep 30099
tcp 0 0 127.0.0.1:30099 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:53649 127.0.0.1:30099 ESTABLISHED
tcp 4586 0 127.0.0.1:30099 127.0.0.1:53649 ESTABLISHED


Replies (3)

RE: No response from an externally spawned fastcgi server. - Added by gstrauss over 4 years ago

from flup.server.fcgi import WSGIServer

Did you mean FastCGIServer in your flup?

BTW, instead of using fastcgi, you should prefer to use mod_scgi with WSGI. See HowToPythonWSGI

RE: No response from an externally spawned fastcgi server. - Added by iamrhari over 4 years ago

Did you mean FastCGIServer in your flup?

No. The REST service is built over bottle framework which supports WSGI interface. The reason for using flup was to be the fcgi/wsgi gateway between lighttpd and bottle.

By using mod_scgi, will I be able to eliminate the need for flup altogether?

Again bottle is NOT explicitly listed a supported server @ http://wsgi.readthedocs.io/en/latest/servers.html

RE: No response from an externally spawned fastcgi server. - Added by gstrauss over 4 years ago

You're arguing that because you did not read it in user-maintained documentation that bottle does not support WSGI?
Well, Bottle is a framework, not a server, and is listed on http://wsgi.readthedocs.io/en/latest/frameworks.html
Therefore, you should not need flup as an intermediary if you use mod_scgi with scgi.protocol = "uwsgi" with Bottle configured to use WSGI.

    (1-3/3)