cherryd/fastcgi/lighttpd

68 views
Skip to first unread message

Eric Abrahamsen

unread,
Jul 1, 2008, 11:43:08 AM7/1/08
to cherryp...@googlegroups.com
I noticed the new cherryd utility comes with the ability to handle
FCGI servers via flup. I've been working with the regular lighttpd
configuration that uses a script file. Since httpd starts a process of
its own, is it possible to use it in conjunction with another
webserver like lighttpd? I've tried connecting via a socket file,
rather than host/port combination, but it seems to want to use host/
port even with server.socket_file set. Can this be done, or am I
barking up the wrong tree?

Thanks,
Eric

Robert Brewer

unread,
Jul 1, 2008, 12:19:19 PM7/1/08
to cherryp...@googlegroups.com

I'm sure it can, it'll just take a little glue. Try modifying cherryd as
follows:

sock_file = cherrypy.config.get('server.socket_file', None)
if sock_file:
bindAddress = sock_file
else:
fastcgi_port = cherrypy.config.get('server.socket_port', 4000)
fastcgi_bindaddr = cherrypy.config.get('server.socket_host',
'0.0.0.0')
bindAddress = (fastcgi_bindaddr, fastcgi_port)

Whether that works or not, please open a ticket. :)
http://www.cherrypy.org/newticket


Robert Brewer
fuma...@aminus.org

Eric Abrahamsen

unread,
Jul 2, 2008, 1:50:31 AM7/2/08
to cherryp...@googlegroups.com
Done: http://www.cherrypy.org/ticket/833

I tried with that, and the engine got as far as starting the monitor
threads before it blew up like so:

ENGINE Error in HTTP server: shutting down
Traceback (most recent call last):
File "/home/user/lib/python2.5/cherrypy/process/servers.py", line
73, in _start_http_thread
self.httpserver.start()
File "/home/user/lib/python2.5/cherrypy/process/servers.py", line
144, in start
self.fcgiserver.run()
File "build/bdist.linux-i686/egg/flup/server/fcgi.py", line 113, in
run
ret = ThreadedServer.run(self, sock)
File "build/bdist.linux-i686/egg/flup/server/threadedserver.py",
line 68, in run
self._installSignalHandlers()
File "build/bdist.linux-i686/egg/flup/server/threadedserver.py",
line 153, in _installSignalHandlers
signal.signal(sig, self._intHandler)
ValueError: signal only works in main thread

I'm testing this with a barebones "hello world" setup. Lighttpd is not
running at this point, not sure if that makes any difference.

python cherryd -c site.conf -f

site.conf
#####
[global]
server.socket_file: '/tmp/fcgi.sock'
tree.myapp: cherrypy.Application(wf.root, "/",)

wf/__init__.py
#####
import cherrypy

class HelloWorld:
@cherrypy.expose
def index(self):
return "Running on cherryd"

root = HelloWorld()

Robert Brewer

unread,
Jul 23, 2008, 12:19:52 AM7/23/08
to cherryp...@googlegroups.com

georgem has been doing some great work on getting this going--please try
out trunk and let us know how it goes.


Robert Brewer
fuma...@aminus.org

Eric Abrahamsen

unread,
Jul 23, 2008, 1:33:29 AM7/23/08
to cherryp...@googlegroups.com

Starts beautifully. I'll try it with the full lighttpd stack when I
have a little more time, but I don't see why that wouldn't work.
Thanks a lot to georgem et al. for all the work! Cherrypy continues to
rock.

E


>
>
>
> Robert Brewer
> fuma...@aminus.org
>
>
> >

Eric Abrahamsen

unread,
Jul 24, 2008, 6:23:57 AM7/24/08
to cherryp...@googlegroups.com
okay, I think I spoke too soon. It worked once, but hasn't worked
since (very weird, since nothing in my environment has changed, so far
as I can tell). The next few times I tried it it died with the
following error:

File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 95, in wait
raise self.interrupt
error: (95, 'Operation not supported')

The last time it died with that error, twice, and then got into an
infinite loop between wspbus.py:315 and wspbus.py:157, log and
publish, back and forth. I'm pasting everything below; the log/publish
loop continued until it hit max recursion depth...

Sorry to be a spoilsport,
Eric


[24/Jul/2008:05:17:56] ENGINE Error in HTTP server: shutting down


Traceback (most recent call last):

File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",

line 73, in _start_http_thread
self.httpserver.start()

File "/home/taojian/lib/python2.5/cherrypy/wsgiserver/__init__.py",
line 1377, in start
raise socket.error, msg
error: (95, 'Operation not supported')

[24/Jul/2008:05:17:56] ENGINE Bus STOPPING
[24/Jul/2008:05:17:56] ENGINE HTTP Server
cherrypy._cpwsgi_server.CPWSGIServer('/tmp/fcgi.sock') already shut down
[24/Jul/2008:05:17:56] ENGINE Stopped thread 'Autoreloader'.
[24/Jul/2008:05:17:56] ENGINE Error in 'start' listener <bound method
Server.start of <cherrypy._cpserver.Server object at 0x9b6df4c>>


Traceback (most recent call last):

File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
147, in publish
output.append(listener(*args, **kwargs))
File "/home/taojian/lib/python2.5/cherrypy/_cpserver.py", line 89,
in start
ServerAdapter.start(self)
File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 60, in start
self.wait()
File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 95, in wait
raise self.interrupt
error: (95, 'Operation not supported')

[24/Jul/2008:05:17:56] ENGINE Shutting down due to error in start
listener:


Traceback (most recent call last):

File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
180, in start
self.publish('start')
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
147, in publish
output.append(listener(*args, **kwargs))
File "/home/taojian/lib/python2.5/cherrypy/_cpserver.py", line 89,
in start
ServerAdapter.start(self)
File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 60, in start
self.wait()
File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 95, in wait
raise self.interrupt
error: (95, 'Operation not supported')

[24/Jul/2008:05:17:56] ENGINE Bus STOPPING
[24/Jul/2008:05:17:56] ENGINE HTTP Server
cherrypy._cpwsgi_server.CPWSGIServer('/tmp/fcgi.sock') already shut down
[24/Jul/2008:05:17:56] ENGINE No thread running for Autoreloader.
[24/Jul/2008:05:17:56] ENGINE Stopped thread '_TimeoutMonitor'.
[24/Jul/2008:05:17:56] ENGINE Bus STOPPED
[24/Jul/2008:05:17:56] ENGINE Bus EXITING
[24/Jul/2008:05:17:56] ENGINE Bus EXITED
Exception in thread HTTPServer Thread-3 (most likely raised during
interpreter shutdown):


Traceback (most recent call last):

File "/usr/local/lib/python2.5/threading.py", line 460, in
__bootstrap
File "/usr/local/lib/python2.5/threading.py", line 440, in run
File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
line 88, in _start_http_thread
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
198, in exit
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
287, in stop
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
157, in publish
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
315, in log
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
157, in publish
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
315, in log
File "/home/taojian/lib/python2.5/cherrypy/process/wspbus.py", line
157, in publish

Robert Brewer

unread,
Jul 24, 2008, 12:47:25 PM7/24/08
to cherryp...@googlegroups.com
Eric Abrahamsen wrote:
> okay, I think I spoke too soon. It worked once, but hasn't worked
> since (very weird, since nothing in my environment has changed, so far
> as I can tell). The next few times I tried it it died with the
> following error:
>
> File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
> line 95, in wait
> raise self.interrupt
> error: (95, 'Operation not supported')
>
> The last time it died with that error, twice, and then got into an
> infinite loop between wspbus.py:315 and wspbus.py:157, log and
> publish, back and forth. I'm pasting everything below; the log/publish
> loop continued until it hit max recursion depth...

OK, first things first. http://www.cherrypy.org/changeset/2027 should
fix the infinite loop.

> [24/Jul/2008:05:17:56] ENGINE Error in HTTP server: shutting down
> Traceback (most recent call last):
> File "/home/taojian/lib/python2.5/cherrypy/process/servers.py",
> line 73, in _start_http_thread
> self.httpserver.start()
> File "/home/taojian/lib/python2.5/cherrypy/wsgiserver/__init__.py",
> line 1377, in start
> raise socket.error, msg
> error: (95, 'Operation not supported')

Why is wsgiserver being run? That should be unsubscribed when you choose
FastCGI (via the '-f' arg to cherryd).


Robert Brewer
fuma...@aminus.org

Eric Abrahamsen

unread,
Jul 27, 2008, 6:29:28 AM7/27/08
to cherryp...@googlegroups.com
Brilliant! All the lights come on, and it works with the full lighttpd
stack. Updating the CP code indeed fixed the infinite loop, and
remembering to use the -f option to cherryd (ahem), fixed the other
problem. :)

Thanks again!
Eric

Reply all
Reply to author
Forward
0 new messages