[Zope-CVS] CVS: Packages/Startup/Controller - ZctlLib.py:1.3

Chris McDonough chrism@zope.com
Fri, 3 Jan 2003 00:46:22 -0500


Update of /cvs-repository/Packages/Startup/Controller
In directory cvs.zope.org:/tmp/cvs-serv20570/Controller

Modified Files:
	ZctlLib.py 
Log Message:
Rework logger sections to not require Python-style constructors.


=== Packages/Startup/Controller/ZctlLib.py 1.2 => 1.3 ===
--- Packages/Startup/Controller/ZctlLib.py:1.2	Thu Jan  2 11:41:14 2003
+++ Packages/Startup/Controller/ZctlLib.py	Fri Jan  3 00:46:20 2003
@@ -114,7 +114,7 @@
         args = [start_script] + [config_location] + opts + [arg]
         wait = self._getConfigValue('debug_mode')
         try:
-            apply(self._spawnPython, args, {'wait':wait})
+            self._spawnPython(*args, **{'wait':wait})
         except KeyboardInterrupt:
             if not wait:
                 raise
@@ -158,7 +158,7 @@
         """
             Print a message showing the status of the Zope appserver,
             including:
-            
+            - Whether Zope is up or down
             - PIDs of appserver processes
 
             Syntax:  status
@@ -166,7 +166,13 @@
         """
         Report on process ids
         """
+        lock_status = self.lockFile()
+        self._report('%-20s : %s' % ('Running', lock_status and 'yes' or 'no'))
+        if not lock_status:
+            return
+
         pidfile_name = self._getConfigValue('pid_filename')
+
         try:
             pids = get_pids(pidfile_name)
         except IOError:
@@ -174,7 +180,7 @@
             self._report('Could not report status (maybe Zope isnt running?)')
             return
 
-        self._report( '%-20s : %s' % ( 'PIDS', pids ))
+        self._report( '%-20s : %s' % ( 'Main PID', pids[0] ))
 
     def stop(self, arg=None):
         """
@@ -351,6 +357,14 @@
         inituser.write('%s:%s' % (username, password))
         self._report('Wrote %s' % os.path.abspath(fname))
 
+    def reload(self, args):
+        """
+            Reload your Zope configuration file.
+        """
+        self._reconfigure()
+        self._report('Reloaded configuration from %s' %
+                     self._getConfigLocation())
+
     #
     #   Helper functions
     #
@@ -362,8 +376,8 @@
     def _help( self, method_name ):
         self._report( normalizeDocstring( getattr( self, method_name ) ) )
 
-    def _setConfig( self, config ):
-        self._config = config
+    def _reconfigure(self):
+        self._config = configure(self._config_location, self._overrides)
 
     def _setConfigLocation(self, config_location):
         self._config_location = config_location
@@ -630,17 +644,19 @@
                 'config-path']
         return [a for a in meta if a.startswith(text) ]
     
-    do_start         = _MAKEDO( 'start' )
-    do_restart       = _MAKEDO( 'restart' )
-    do_logopenclose  = _MAKEDO( 'logopenclose' )
-    do_stop          = _MAKEDO( 'stop' )
-    do_status        = _MAKEDO( 'status' )
-    do_show          = _MAKEDO( 'show' )
-    do_run           = _MAKEDO( 'run' )
-    do_debug         = _MAKEDO( 'debug' )
-    do_quit          = _MAKEDO( 'quit' )
-    do_shell         = _MAKEDO( 'shell' )
+    do_start          = _MAKEDO( 'start' )
+    do_restart        = _MAKEDO( 'restart' )
+    do_logopenclose   = _MAKEDO( 'logopenclose' )
+    do_stop           = _MAKEDO( 'stop' )
+    do_status         = _MAKEDO( 'status' )
+    do_show           = _MAKEDO( 'show' )
+    do_run            = _MAKEDO( 'run' )
+    do_debug          = _MAKEDO( 'debug' )
+    do_quit           = _MAKEDO( 'quit' )
+    do_shell          = _MAKEDO( 'shell' )
     do_write_inituser = _MAKEDO( 'write_inituser')
+    do_reload         = _MAKEDO( 'reload' )
+
     #
     #   Command-line processing
     #
@@ -671,11 +687,10 @@
                 if k.startswith('--'):
                     k = k[2:]
                     overrides[k] = v
-        config = configure(config_location, overrides)
-        self._engine._setConfig(config)
         self._engine._setConfigLocation(config_location)
         self._engine._setCommandLineOpts(opts)
         self._engine._setOverrides(overrides)
+        self._engine._reconfigure()
         if args:
             self.cmdqueue.append(' '.join(args))
             self.cmdqueue.append('EOF')