On Aug 18, 12:37 pm, Albert Hopkins <mar...@letterboxes.org> wrote:
> On Wed, 2010-08-18 at 06:58 -0700, Nan wrote:
> > Ah, I'd been told that there would be no conflict, and that this was
> > just reloading the configuration, not restarting Apache.
>
> > I do need the web app to instruct Apache to reload because just before
> > this it's creating new VirtualHosts that need to be recognized.  Is
> > there a better way to do this (e.g. to say "start doing this once I'm
> > finished")?
>
> > I'm getting a status code and output from the call before the Django
> > script stops executing... Is there a way to stop waiting for the
> > process to complete once I have those?
>
> I have a wireless router with a built in web server.  Sometimes it needs
> to "reload" it's config.  Basically what it's doing is rebooting the
> entire router (I can see this if I'm actuall watching the router).  All
> it is doing, I'm pretty sure, is calling some program that forks another
> process and then exits the main program.  The forked process then
> reboots the router.  Meanwhile before that happens the web server sends
> a response. Basically in the response it sends an HTTP Refresh with x
> number of seconds.  Presumably x is longer than the time it requires for
> the router to reboot.  The router reboots, the browser refreshes and
> viola.
>
> You probably need to so something similar in that your request calls a
> program that forks off and restarts apaches.  It should probably not do
> so immediately so that your request has time to send a response with a
> refresh header (but that shouldn't take long).  After a second or so,
> apache will have restarted and the browser will have refreshed.
>
> so (untested):
>
> def reload(request):
>     subprocess.call(['my_apache_reloader']) # this should fork and exit
>     response = HttpResponse()
>     response['Refresh']='3; url=%s' % reverse(home) # chk back in 3 secs
>     return response
>
> BTW There is a Django mailing list where this might be more appropriate
> to discuss.
>
> -a

Sadly, questions about subprocess spawning on the Django lists seem to
get referred back to the Python lists when they get an answer at all.
You've been very helpful, though, so thank you.

I think I'll have to mark in the database when the server needs
restarting, and run a cron job to check that and reload Apache from a
non-Apache process.  It will mean delayed creation of the Virtual
Hosts and no immediate feedback to indicate success or failure, but it
doesn't look like there's much alternative.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to