cwctl.py
branchstable
changeset 3180 6bab5746ebf5
parent 2905 b23bbb31368c
child 3182 76ad941f694e
--- a/cwctl.py	Fri Sep 11 13:40:49 2009 +0200
+++ b/cwctl.py	Fri Sep 11 14:16:06 2009 +0200
@@ -146,6 +146,7 @@
             else:
                 self.run_arg(appid)
 
+
 # base commands ###############################################################
 
 class ListCommand(Command):
@@ -359,7 +360,7 @@
 
 # instance commands ########################################################
 
-class StartInstanceCommand(InstanceCommand):
+class StartInstanceCommand(InstanceCommandFork):
     """Start the given instances. If no instance is given, start them all.
 
     <instance>...
@@ -409,8 +410,10 @@
             msg = "%s seems to be running. Remove %s by hand if necessary or use \
 the --force option."
             raise ExecutionError(msg % (appid, pidf))
-        helper.start_command(config, debug)
-        return True
+        helper.start_server(config, debug)
+        if not debug:
+            # in debug mode, we reach this point once the instance is stopped...
+            print 'instance %s %s' % (appid, self.actionverb)
 
 
 class StopInstanceCommand(InstanceCommand):
@@ -463,8 +466,7 @@
         print 'instance %s stopped' % appid
 
 
-class RestartInstanceCommand(StartInstanceCommand,
-                                StopInstanceCommand):
+class RestartInstanceCommand(StartInstanceCommand):
     """Restart the given instances.
 
     <instance>...
@@ -489,8 +491,7 @@
                 print '*'*72
                 if not ASK.confirm('%s instance %r ?' % (self.name, appid)):
                     continue
-            self.stop_instance(appid)
-            stopped.append(appid)
+            StopInstanceCommand().stop_instance(appid)
         forkcmd = [w for w in sys.argv if not w in args]
         forkcmd[1] = 'start'
         forkcmd = ' '.join(forkcmd)
@@ -500,9 +501,8 @@
                 sys.exit(status)
 
     def restart_instance(self, appid):
-        self.stop_instance(appid)
-        if self.start_instance(appid):
-            print 'instance %s %s' % (appid, self.actionverb)
+        StopInstanceCommand().stop_instance(appid)
+        self.start_instance(appid)
 
 
 class ReloadConfigurationCommand(RestartInstanceCommand):
@@ -553,9 +553,7 @@
             print "running with pid %s" % (pid)
 
 
-class UpgradeInstanceCommand(InstanceCommandFork,
-                                StartInstanceCommand,
-                                StopInstanceCommand):
+class UpgradeInstanceCommand(InstanceCommandFork):
     """Upgrade an instance after cubicweb and/or component(s) upgrade.
 
     For repository update, you will be prompted for a login / password to use
@@ -661,7 +659,7 @@
             print '-> migration needed from %s to %s for %s' % (fromversion, toversion, cube)
         # only stop once we're sure we have something to do
         if not (cwcfg.mode == 'dev' or self.config.nostartstop):
-            self.stop_instance(appid)
+            StopCommand().stop_instance(appid)
         # run cubicweb/componants migration scripts
         mih.migrate(vcconf, reversed(toupgrade), self.config)
         # rewrite main configuration file
@@ -684,7 +682,7 @@
         print
         print '-> instance migrated.'
         if not (cwcfg.mode == 'dev' or self.config.nostartstop):
-            self.start_instance(appid)
+            StartCommand().start_instance(appid)
         print