2

I have a lighttpd server that I want to run a python application using fastcgi. I followed the example on the lighty homepage, but I can't seem to get lighty to execute the python script. This is my fastcgi section in lighttpd.conf:

fastcgi.server = (
    ".py" =>
    (
        "python-fcgi" =>
        (
         "socket" => "/tmp/fastcgi.python.socket",
         "bin-path" => "/usr/bin/login_flask/fcgitest.py",
         "check-local" => "disable",
         "max-procs" => 1,
        )
    ))

This is the content of fcgitest.py:

#!/usr/bin/python3
def myapp(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/plain')])
    return ['Hello World!\n']

if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp, bindAddress="/tmp/fastcgi.python.socket").run()

When I restart lighty with this configuration, I can see that the python process is started and I don't get any error from lighty. However, when I go to https://localhost:444/test.py it just keeps loading forever. Nothing is written in access.log or error.log. If anyone could give me a hint on how to investigate this I would be grateful.

EDIT: I enabled fastcgi.debug, and this is written to the error log when I go to the URL mentioned above. It still keeps loading forever:

2019-07-26 11:53:26: (gw_backend.c.914) gw - found a host  0 
2019-07-26 11:53:26: (gw_backend.c.227) got proc: pid: 2628 socket: unix:/tmp/fastcgi.python.socket-0 load: 1 
Gasp0de
  • 249
  • 2
  • 12
  • Is there any information on the client-side? I'd check the developer tools in the browser. – oxr463 Jul 26 '19 at 12:32
  • No, nothing. The webserver doesn't respond to the request at all. I think it correctly decides that it has to route the request to python but then somewhere the communication between lighttpd and the python script doesn't work. I'll change the python script so that it touches a file. That way I'll know if it ran. – Gasp0de Jul 26 '19 at 12:37

1 Answers1

1

Per your fcgitest.py,

if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp, bindAddress="/tmp/fastcgi.python.socket").run()

None of the examples include the bindAddress parameter that you have here.

Try this instead,


if __name__ == '__main__':
    from flup.server.fcgi import WSGIServer
    WSGIServer(myapp).run()
oxr463
  • 199
  • 1
  • 2
  • 11