[mod_python] Child shutdowns?

Greg Stein gstein at lyra.org
Fri Aug 29 14:56:55 EST 2003


On Fri, Aug 29, 2003 at 05:11:28PM -0400, Gregory (Grisha) Trubetskoy wrote:
> 
> Barry
> 
> If I remember this correctly, from the viewpoint of Apache, to create a
> server object (or server_rec structure) you need to have a request,
> because a server is created based on what the "Host:" header says (if it

Nope, sorry.

The server_rec structures are created at server-startup time when we parse
the configuration file. There is a server_rec per virtual host, plus one
for the default server.

At request time, the appropriate server_rec is looked up and passed along
as part of the request processing.

> is there at all) and by then going throught the config to see if there is
> anything relevant. Once a server is created, it is cached and reused, but
> it is not created at Apache startup (as an extreme example, mod_vhost
> allows you to create an unlimited number of virtual servers without
> specifying them in the config at all - so there is no way to know what the
> server name is until a request for it comes in).

Dunno how mod_vhost does it. The typical scenario is the construction at
startup time.

> I don't know if Apache provides a way to do something at server creation
> time, I'll check it out, but it's unlikely. For right now, the only way to
> register a server cleanup is from within a request :-(

The post_config hook is possibly one place to do this. It gets a pool
associated with the process.

There is also a child_init hook, which I believe is called whenever a new
child is spun up. That is probably a more appropriate place. It gets a
pool associated with the child.

If you can get a function registered as a cleanup on that pool, then
you'll be all set.

Cheers,
-g

> 
> Grisha
> 
> On Fri, 29 Aug 2003, Barry Warsaw wrote:
> 
> > I'm very likely missing it, but is there some way to run a callable when
> > the child processes are terminated (i.e. through apachectl stop)?
> >
> > Seems like the server object's register_cleanup() ought to do it, except
> > that I have some startup code that gets run when my main module is
> > imported and at that point I don't have a request object to use as the
> > first argument to register_cleanup().
> >
> > Any hints (or examples!)?
> >
> > Thanks,
> > -Barry
> >
> >
> > _______________________________________________
> > Mod_python mailing list
> > Mod_python at modpython.org
> > http://mailman.modpython.org/mailman/listinfo/mod_python
> >
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

-- 
Greg Stein, http://www.lyra.org/


More information about the Mod_python mailing list