diff -r edfe43ceaa35 -r bd0126d17e83 cwctl.py --- a/cwctl.py Thu Sep 10 08:13:22 2009 +0200 +++ b/cwctl.py Fri Sep 11 15:57:34 2009 +0200 @@ -153,6 +153,7 @@ else: self.run_arg(appid) + # base commands ############################################################### class ListCommand(Command): @@ -366,7 +367,7 @@ # instance commands ######################################################## -class StartInstanceCommand(InstanceCommand): +class StartInstanceCommand(InstanceCommandFork): """Start the given instances. If no instance is given, start them all. ... @@ -398,17 +399,15 @@ def start_instance(self, appid): """start the instance's server""" - # use get() since start may be used from other commands (eg upgrade) - # without all options defined - debug = self.get('debug') - force = self.get('force') - loglevel = self.get('loglevel') + debug = self['debug'] + force = self['force'] + loglevel = self['loglevel'] config = cwcfg.config_for(appid) if loglevel is not None: loglevel = 'LOG_%s' % loglevel.upper() config.global_set_option('log-threshold', loglevel) config.init_log(loglevel, debug=debug, force=True) - if self.get('profile'): + if self['profile']: config.global_set_option('profile', self.config.profile) helper = self.config_helper(config, cmdname='start') pidf = config['pid-file'] @@ -416,8 +415,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): @@ -470,8 +471,7 @@ print 'instance %s stopped' % appid -class RestartInstanceCommand(StartInstanceCommand, - StopInstanceCommand): +class RestartInstanceCommand(StartInstanceCommand): """Restart the given instances. ... @@ -490,14 +490,12 @@ print ('some specific start order is specified, will first stop all ' 'instances then restart them.') # get instances in startorder - stopped = [] for appid in args: if askconfirm: 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) @@ -507,9 +505,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): @@ -560,9 +557,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 @@ -618,10 +613,6 @@ }), ) - def ordered_instances(self): - # need this since mro return StopInstanceCommand implementation - return InstanceCommand.ordered_instances(self) - def upgrade_instance(self, appid): print '\n' + underline_title('Upgrading the instance %s' % appid) from logilab.common.changelog import Version @@ -668,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 @@ -691,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