[svn] commit: r200 - /branches/f2f200910/src/bin/bind10/bind10.py
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Oct 29 23:22:36 UTC 2009
Author: shane
Date: Thu Oct 29 23:22:36 2009
New Revision: 200
Log:
Start parking lot. Make abnormal shutdown a bit nicer.
Modified:
branches/f2f200910/src/bin/bind10/bind10.py
Modified: branches/f2f200910/src/bin/bind10/bind10.py
==============================================================================
--- branches/f2f200910/src/bin/bind10/bind10.py (original)
+++ branches/f2f200910/src/bin/bind10/bind10.py Thu Oct 29 23:22:36 2009
@@ -71,10 +71,9 @@
stderr=dev_null,
close_fds=True,
env=c_channel_env,)
- except OSError:
+ except:
return "Unable to start msgq"
self.processes[c_channel.pid] = c_channel
- self.cc_process = c_channel
if self.verbose:
sys.stdout.write("Started msgq with PID %d\n" % c_channel.pid)
@@ -108,8 +107,34 @@
self.processes[bind_cfgd.pid] = bind_cfgd
if self.verbose:
sys.stdout.write("Started bind-cfgd with PID %d\n" % bind_cfgd.pid)
+
+ # start the parking lot
+ # XXX: this must be read from the configuration manager in the future
+ if self.verbose:
+ sys.stdout.write("Starting parkinglot\n")
+ try:
+ parkinglot = subprocess.Popen("parkinglot",
+ stdin=dev_null,
+ stdout=dev_null,
+ stderr=dev_null,
+ close_fds=True,
+ env={},)
+ except:
+ c_channel.kill()
+ bind_cfgd.kill()
+ return "Unable to start parkinglot"
+ self.processes[parkinglot.pid] = parkinglot
+ if self.verbose:
+ sys.stdout.write("Started parkinglot with PID %d\n" % parkinglot.pid)
+
+ # remember our super-important process
+ self.cc_process = c_channel
return None
+
+ def stop_all_processes(self):
+ """Stop all processes."""
+ self.cc_session.group_sendmsg({ "shutdown": True }, "Boss")
def stop_process(self, process):
"""Stop the given process, friendly-like."""
@@ -121,12 +146,14 @@
if self.verbose:
sys.stdout.write("Stopping the server.\n")
# first try using the BIND 10 request to stop
- unstopped_processes = []
- for process in self.processes.values():
- if not self.stop_process(process):
- unstopped_processes.append(process)
+ if self.cc_session:
+ try:
+ self.stop_all_processes()
+ except:
+ pass
+ time.sleep(0.1) # XXX: some delay probably useful... how much is uncertain
# next try sending a SIGTERM
- processes_to_stop = unstopped_processes
+ processes_to_stop = list(self.processes)
unstopped_processes = []
for process in processes_to_stop:
if self.verbose:
@@ -155,7 +182,6 @@
pass
if self.verbose:
sys.stdout.write("All processes ended, server done.\n")
- sys.exit(0)
def reap(self, pid, exit_status):
"""The process specified by pid has exited with the value
@@ -166,10 +192,12 @@
self.dead_processes[process.pid] = process
if self.verbose:
sys.stdout.write("Process %d died.\n" % pid)
- if pid == self.cc_process.pid:
+ if self.cc_process and (pid == self.cc_process.pid):
if self.verbose:
sys.stdout.write("The msgq process died, shutting down.\n")
- self.shutdown()
+ return False
+ else:
+ return True
if __name__ == "__main__":
def reaper(signal_number, stack_frame):
@@ -182,7 +210,12 @@
if o.errno == errno.ECHILD: break
raise
if pid == 0: break
- boss_of_bind.reap(pid, exit_status)
+ if not boss_of_bind.reap(pid, exit_status):
+ signal.signal(signal.SIGCHLD, signal.SIG_DFL)
+ boss_of_bind.shutdown()
+ sys.exit(0)
+
+
def get_signame(signal_number):
"""Return the symbolic name for a signal."""
More information about the bind10-changes
mailing list