Project

General

Profile

[Solved] Lighttpd never sends response

Added by midnight_milloir about 6 years ago

I've got a flask app that I'd like to run inside of lighttpd using fastcgi. I'm running this on a Raspberry Pi 3 with Raspbian Stretch Lite. When I type the IP of the pi, lighttpd definitely receives the connection, however, it hangs eternally. I can't figure out why it does that.

Here is the output from lighttpd when I type the IP into my browser.

2018-01-04 22:33:24: (log.c.217) server started
2018-01-04 22:33:59: (response.c.350) -- splitting Request-URI
2018-01-04 22:33:59: (response.c.351) Request-URI : /
2018-01-04 22:33:59: (response.c.352) URI-scheme : http
2018-01-04 22:33:59: (response.c.353) URI-authority : 172.30.26.14:8080
2018-01-04 22:33:59: (response.c.354) URI-path (raw) : /
2018-01-04 22:33:59: (response.c.355) URI-path (clean): /
2018-01-04 22:33:59: (response.c.356) URI-query :
2018-01-04 22:33:59: (response.c.350) -- splitting Request-URI
2018-01-04 22:33:59: (response.c.351) Request-URI : /application.fcgi/
2018-01-04 22:33:59: (response.c.352) URI-scheme : http
2018-01-04 22:33:59: (response.c.353) URI-authority : 172.30.26.14:8080
2018-01-04 22:33:59: (response.c.354) URI-path (raw) : /application.fcgi/
2018-01-04 22:33:59: (response.c.355) URI-path (clean): /application.fcgi/
2018-01-04 22:33:59: (response.c.356) URI-query :
2018-01-04 22:33:59: (response.c.490) -- before doc_root
2018-01-04 22:33:59: (response.c.491) Doc-Root : /var/www/
2018-01-04 22:33:59: (response.c.492) Rel-Path : /application.fcgi/
2018-01-04 22:33:59: (response.c.493) Path :
2018-01-04 22:33:59: (response.c.542) -- after doc_root
2018-01-04 22:33:59: (response.c.543) Doc-Root : /var/www/
2018-01-04 22:33:59: (response.c.544) Rel-Path : /application.fcgi/
2018-01-04 22:33:59: (response.c.545) Path : /var/www/application.fcgi/
2018-01-04 22:33:59: (response.c.562) -- logical > physical
2018-01-04 22:33:59: (response.c.563) Doc-Root : /var/www/
2018-01-04 22:33:59: (response.c.564) Basedir : /var/www/
2018-01-04 22:33:59: (response.c.565) Rel-Path : /application.fcgi/
2018-01-04 22:33:59: (response.c.566) Path : /var/www/application.fcgi/
2018-01-04 22:33:59: (response.c.583) -
handling physical path
2018-01-04 22:33:59: (response.c.584) Path : /var/www/application.fcgi/
2018-01-04 22:33:59: (response.c.745) -- after pathinfo check
2018-01-04 22:33:59: (response.c.746) Path : /var/www/application.fcgi
2018-01-04 22:33:59: (response.c.747) URI : /application.fcgi
2018-01-04 22:33:59: (response.c.748) Pathinfo : /
2018-01-04 22:33:59: (response.c.753) -- handling subrequest
2018-01-04 22:33:59: (response.c.754) Path : /var/www/application.fcgi
2018-01-04 22:33:59: (mod_fastcgi.c.3500) handling it in mod_fastcgi
2018-01-04 22:33:59: (mod_fastcgi.c.2875) got proc: pid: 784 socket: unix:/tmp/fastcgi.socket-0 load: 1

It hangs on that last line forever, until I kill the process with ctrl c. Here is the rest of the output once I do that.

^C2018-01-04 22:39:11: (server.c.1751) [note] graceful shutdown started
2018-01-04 22:39:11: (mod_fastcgi.c.2424) unexpected end-of-file (perhaps the fastcgi process died): pid: 784 socket: unix:/tmp/fastcgi.socket-0
2018-01-04 22:39:11: (mod_fastcgi.c.3129) child exited, pid: 784 status: 0
2018-01-04 22:39:11: (mod_fastcgi.c.3143) --- fastcgi spawning \n\tsocket unix:/tmp/fastcgi.socket-0 \n\tcurrent: 1 / 1
2018-01-04 22:39:11: (mod_fastcgi.c.900) new proc, socket: 0 /tmp/fastcgi.socket-0
2018-01-04 22:39:11: (mod_fastcgi.c.3175) response not received, request sent: 886 on socket: unix:/tmp/fastcgi.socket-0 for /application.fcgi?, closing connection
2018-01-04 22:39:11: (mod_fastcgi.c.1642) released proc: pid: 800 socket: unix:/tmp/fastcgi.socket-0 load: 0
^C2018-01-04 22:39:12: (server.c.1828) server stopped by UID = 0 PID = 0
Traceback (most recent call last):
File "/var/www/TimeClock/application.fcgi", line 3, in module
from modules import app
File "/var/www/TimeClock/modules/__init__.py", line 1, in module

Looking at the output, I can't decipher where the problem would be occurring. Also, the traceback at the bottom always seems to cutoff before it finishes printing. I have no idea what's going on there too.

Here is my lighttpd.conf file.

server.modules   += ( "mod_fastcgi" )
server.modules += ( "mod_rewrite" )
fastcgi.debug = 1
debug.log-request-handling = "enable"
debug.log-file-not-found = "enable"
server.username = "lighttpd"
server.groupname = "lighttpd"
server.document-root = "/var/www/"
server.port = 80
$SERVER["socket"] == ":80" {
mimetype.assign = (
".html" => "text/html"
)
url.rewrite-once = (
"^(/modules/static($|/.*))$" => "$1",
"^(/.*)$" => "/application.fcgi$1"
)
$HTTP["host"] =~ "$" {
server.document-root = "/var/www/"
fastcgi.server = ( "application.fcgi" =>
(( "socket" => "/tmp/fastcgi.socket",
"bin-path" => "/home/pi/timeclock_venv/bin/python3 /var/www/TimeClock/application.fcgi",
"max-procs" => 1,
"bin-environment" => (
"REAL_SCRIPT_NAME" => ""
),
"check-local" => "disable"
))
)
}
}

And here is my fastcgi file, named application.fcgi.

#!/usr/bin/python3
from flup.server.fcgi import WSGIServer
from modules import app
if name == '__main__':
WSGIServer(app).run()

I have all the dependencies of my flask project installed in a virtualenv, which I activate before running the application.fcgi script. I don't understand what I'm missing here. Any help is appreciated.


Replies (1)

RE: Lighttpd never sends response - Added by gstrauss about 6 years ago

I suggest trying a simpler FastCGI app, such as "Hello World" before continuing. See HowToPythonWSGI After getting something simple working, I think you'll find the problem is your application.fcgi not responding.

    (1-1/1)