asmodai wrote:
> On May 30, 11:50 pm, "Robert Brewer"
<fuman... amor.org> wrote:
> > The problem is most likely that your WSGI server
is starting its own
> > threads, but CP doesn't know how to tell it to
shut down
> those threads.
> > Ideally, you'd write a very small adapter so that,
when the
> SIGTERM is
> > handled, cherrypy.server (really a server manager)
will send a stop
> > message to the flup.server.fcgi.WSGIServer. See
> >
http://www.cherrypy.org/wiki/ServerAPI#HTTPServerAPI for
a
> discussion of
> > what that adapter layer needs to look like.
>
> Reading that URL and looking at my setup, I do not
think it matches.
> Lighttpd is the one spawning the fcgi process which in
turn starts up
> cherrypy. Cherrypy is not the process in command and as
such is not
> the one in need to send the stop. Lighttpd sends flup a
SIGTERM, flup
> then starts to tear down the process and clean up the
socket.
>
> I suddenly realised the solution was fairly simple and
I tested this
> with the stop/start cycle of lighttpd as well as a
restart:
>
> import cherrypy
> import os
>
> from flup.server.fcgi import WSGIServer
>
> from kouyou.controllers import *
>
> current_dir =
os.path.dirname(os.path.abspath(__file__))
>
> dispatcher = cherrypy.dispatch.RoutesDispatcher()
> dispatcher.connect('home', '',
controller=HomeController())
>
> config = {'/': {'request.dispatch': dispatcher,
> 'tools.staticdir.root':
os.path.join(current_dir,
> 'static')},
> '/css': {'tools.staticdir.on': True,
> 'tools.staticdir.dir': 'css'},
> '/img': {'tools.staticdir.on': True,
> 'tools.staticdir.dir': 'img'}
> }
>
>
> app = cherrypy.tree.mount(None, config=config)
> cherrypy.engine.start(blocking=False)
> try:
> try:
> WSGIServer(app).run()
> except SystemExit:
> raise
> except Exception, e:
> print 'Content-Type: text/plainrnrn',
> print 'Oops...'
> print
> print 'Kouyou detected an internal error:'
> print
> print e
> print
> import traceback
> import StringIO
> tb = StringIO.StringIO()
> traceback.print_exc(file=tb)
> print tb.getvalue()
> finally:
> cherrypy.engine.stop()
>
> Comments/ideas/opinions?
Aha. I hadn't correctly read your initial post; I didn't
realize you
weren't using cherrypy.server.start in the first place.
So; your solution looks fine, except for all those print
statements...what's stdout at that point? Don't tell me that
whole
script is run once per request!
Robert Brewer
System Architect
Amor Ministries
fumanchu amor.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users googlegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribe googlegroups.com
For more options, visit this group at h
ttp://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|