Browse Source

Ensure that process started and process terminated messages are output
regardless of the state of the verbose flag.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac229@3814 e5f2f494-b856-4b98-b285-d166d9295462

Stephen Morris 14 years ago
parent
commit
354c7cc33a
1 changed files with 32 additions and 16 deletions
  1. 32 16
      src/bin/bind10/bind10.py.in

+ 32 - 16
src/bin/bind10/bind10.py.in

@@ -612,27 +612,44 @@ class BoB:
                 raise
                 raise
             if pid == 0: break
             if pid == 0: break
             if pid in self.processes:
             if pid in self.processes:
+
+                # One of the processes we know about.  Get information on it.
                 proc_info = self.processes.pop(pid)
                 proc_info = self.processes.pop(pid)
                 proc_info.restart_schedule.set_run_stop_time()
                 proc_info.restart_schedule.set_run_stop_time()
                 self.dead_processes[proc_info.pid] = proc_info
                 self.dead_processes[proc_info.pid] = proc_info
-                if self.verbose:
-                    sys.stdout.write("[bind10] Process %s (PID %d) died.\n" % 
-                                     (proc_info.name, proc_info.pid))
-                if proc_info.name == "b10-msgq":
-                    if self.verbose and self.runnable:
+
+                # Write out message, but only if in the running state:
+                # During startup and shutdown, these messages are handled
+                # elsewhere.
+                if self.runnable:
+                    if exit_status is None:
+                        sys.stdout.write(
+                            "[bind10] Process %s (PID %d) died: exit status not available" % 
+                            (proc_info.name, proc_info.pid))
+                    else:
+                        sys.stdout.write(
+                            "[bind10] Process %s (PID %d) terminated, exit status = %d\n" % 
+                            (proc_info.name, proc_info.pid, exit_status))
+
+                    # Was it a special process?
+                    if proc_info.name == "b10-msgq":
                         sys.stdout.write(
                         sys.stdout.write(
                                  "[bind10] The b10-msgq process died, shutting down.\n")
                                  "[bind10] The b10-msgq process died, shutting down.\n")
-                    self.runnable = False
+                        self.runnable = False
             else:
             else:
                 sys.stdout.write("[bind10] Unknown child pid %d exited.\n" % pid)
                 sys.stdout.write("[bind10] Unknown child pid %d exited.\n" % pid)
 
 
     def restart_processes(self):
     def restart_processes(self):
-        """Restart any dead processes.
-        Returns the time when the next process is ready to be restarted. 
-          If the server is shutting down, returns 0.
-          If there are no processes, returns None.
-        The values returned can be safely passed into select() as the 
-        timeout value."""
+        """
+            Restart any dead processes:
+
+            * Returns the time when the next process is ready to be restarted. 
+            * If the server is shutting down, returns 0.
+            * If there are no processes, returns None.
+
+            The values returned can be safely passed into select() as the 
+            timeout value.
+        """
         next_restart = None
         next_restart = None
         # if we're shutting down, then don't restart
         # if we're shutting down, then don't restart
         if not self.runnable:
         if not self.runnable:
@@ -649,13 +666,12 @@ class BoB:
             else:
             else:
                 if self.verbose:
                 if self.verbose:
                     sys.stdout.write("[bind10] Resurrecting dead %s process...\n" % 
                     sys.stdout.write("[bind10] Resurrecting dead %s process...\n" % 
-                                     proc_info.name)
+                        proc_info.name)
                 try:
                 try:
                     proc_info.respawn()
                     proc_info.respawn()
                     self.processes[proc_info.pid] = proc_info
                     self.processes[proc_info.pid] = proc_info
-                    if self.verbose:
-                        sys.stdout.write("[bind10] Resurrected %s (PID %d)\n" %
-                                         (proc_info.name, proc_info.pid))
+                    sys.stdout.write("[bind10] Resurrected %s (PID %d)\n" %
+                                     (proc_info.name, proc_info.pid))
                 except:
                 except:
                     still_dead[proc_info.pid] = proc_info
                     still_dead[proc_info.pid] = proc_info
         # remember any processes that refuse to be resurrected
         # remember any processes that refuse to be resurrected