# HG changeset patch # User Sylvain Thénault # Date 1252671366 -7200 # Node ID 6bab5746ebf5e7b06bd6729e3c4a232628a49745 # Parent 0684544f6d0d993c9999e0c9d18598abcc887281 [c-c] fix start/restart commands diff -r 0684544f6d0d -r 6bab5746ebf5 cwctl.py --- 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. ... @@ -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. ... @@ -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 diff -r 0684544f6d0d -r 6bab5746ebf5 etwist/twctl.py --- a/etwist/twctl.py Fri Sep 11 13:40:49 2009 +0200 +++ b/etwist/twctl.py Fri Sep 11 14:16:06 2009 +0200 @@ -18,7 +18,7 @@ cmdname = 'start' cfgname = 'twisted' - def start_command(self, config, debug): + def start_server(self, config, debug): from cubicweb.etwist import server server.run(config, debug) diff -r 0684544f6d0d -r 6bab5746ebf5 server/serverctl.py --- a/server/serverctl.py Fri Sep 11 13:40:49 2009 +0200 +++ b/server/serverctl.py Fri Sep 11 14:16:06 2009 +0200 @@ -210,12 +210,12 @@ cmdname = 'start' cfgname = 'repository' - def start_command(self, ctlconf, debug): + def start_server(self, ctlconf, debug): command = ['cubicweb-ctl start-repository '] if debug: command.append('--debug') command.append(self.config.appid) - return ' '.join(command) + os.system(' '.join(command)) class RepositoryStopHandler(CommandHandler):