--- a/cwctl.py Fri Sep 11 12:42:37 2009 +0200
+++ b/cwctl.py Fri Sep 11 15:55:15 2009 +0200
@@ -152,6 +152,7 @@
else:
self.run_arg(appid)
+
# base commands ###############################################################
class ListCommand(Command):
@@ -365,7 +366,7 @@
# instance commands ########################################################
-class StartInstanceCommand(InstanceCommand):
+class StartInstanceCommand(InstanceCommandFork):
"""Start the given instances. If no instance is given, start them all.
<instance>...
@@ -397,17 +398,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']
@@ -415,8 +414,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):
@@ -469,8 +470,7 @@
print 'instance %s stopped' % appid
-class RestartInstanceCommand(StartInstanceCommand,
- StopInstanceCommand):
+class RestartInstanceCommand(StartInstanceCommand):
"""Restart the given instances.
<instance>...
@@ -489,14 +489,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)
@@ -506,9 +504,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):
@@ -559,9 +556,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
@@ -617,10 +612,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
@@ -667,7 +658,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
@@ -690,7 +681,7 @@
print
print '-> instance migrated.'
if not (cwcfg.mode == 'dev' or self.config.nostartstop):
- self.start_instance(appid)
+ StartCommand().start_instance(appid)
print