def do_restart_process(self, arg): """ Command to restart processes with a strategy and rules. """ if self._upcheck(): args = arg.split() if len(args) < 1: self.ctl.output('ERROR: restart_process requires a strategy and a program name') self.help_restart_process() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output('ERROR: unknown strategy for restart_process. ' 'use one of {}'.format(StartingStrategies._strings())) self.help_restart_process() return processes = args[1:] if not processes or "all" in processes: try: processes = ['{}:*'.format(application_info['application_name']) for application_info in self.supvisors().get_all_applications_info()] except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) processes = [] for process in processes: try: result = self.supvisors().restart_process(strategy, process) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format(process, e.faultString)) else: self.ctl.output('{} restarted: {}'.format(process, result))
def do_restart_application(self, arg): """ Command to restart Supvisors applications using a strategy and rules. """ if self._upcheck(): args = arg.split() if len(args) < 1: self.ctl.output('ERROR: restart_application requires at least a strategy') self.help_restart_application() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output('ERROR: unknown strategy for restart_application.' ' use one of {}'.format(StartingStrategies._strings())) self.help_restart_application() return applications = args[1:] if not applications or "all" in applications: try: applications = [ application_info['application_name'] for application_info in self.supvisors().get_all_applications_info() ] except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) applications = [] for application in applications: try: self.supvisors().restart_application(strategy, application) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format(application, e.faultString)) else: self.ctl.output('{} restarted'.format(application))
def do_start_process_args(self, arg): """ Command to start a process with a strategy, rules and additional arguments. """ if self._upcheck(): args = arg.split() if len(args) < 3: self.ctl.output( 'ERROR: start_process_args requires a strategy, ' 'a program name and extra arguments') self.help_start_process_args() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output( 'ERROR: unknown strategy for start_process_args.' ' use one of {}'.format(StartingStrategies._strings())) self.help_start_process_args() return namespec = args[1] try: result = self.supvisors().start_process( strategy, namespec, ' '.join(args[2:])) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format( namespec, e.faultString)) else: self.ctl.output('{} started: {}'.format(namespec, result))
def do_start_process(self, arg): """ Command to start processes with a strategy and rules. """ if self._upcheck(): args = arg.split() if len(args) < 1: self.ctl.output( 'ERROR: start_process requires at least a strategy') self.help_start_process() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output('ERROR: unknown strategy for start_process.' ' use one of {}'.format( StartingStrategies._strings())) self.help_start_process() return processes = args[1:] if not processes or "all" in processes: try: processes = [ '{}:*'.format(application_info['application_name']) for application_info in self.supvisors().get_all_applications_info() ] except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) processes = [] for process in processes: try: result = self.supvisors().start_process(strategy, process) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format( process, e.faultString)) else: self.ctl.output('{} started: {}'.format(process, result))
def do_restart_application(self, arg): """ Command to restart Supvisors applications using a strategy and rules. """ if self._upcheck(): args = arg.split() if len(args) < 1: self.ctl.output( 'ERROR: restart_application requires at least a strategy') self.help_restart_application() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output( 'ERROR: unknown strategy for restart_application.' ' use one of {}'.format(StartingStrategies._strings())) self.help_restart_application() return applications = args[1:] if not applications or "all" in applications: try: applications = [ application_info['application_name'] for application_info in self.supvisors().get_all_applications_info() ] except xmlrpclib.Fault, e: self.ctl.output('ERROR ({})'.format(e.faultString)) applications = [] for application in applications: try: self.supvisors().restart_application(strategy, application) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format( application, e.faultString)) else: self.ctl.output('{} restarted'.format(application))
def to_starting_strategy(value): """ Convert a string into a StartingStrategies enum. """ strategy = StartingStrategies._from_string(value) if strategy is None: raise ValueError('invalid value for starting_strategy: {}. expected in {}'.format( value, StartingStrategies._strings())) return strategy
def to_starting_strategy(value): """ Convert a string into a StartingStrategies enum. """ strategy = StartingStrategies._from_string(value) if strategy is None: raise ValueError( 'invalid value for starting_strategy: {}. expected in {}'. format(value, StartingStrategies._strings())) return strategy
def do_start_process_args(self, arg): """ Command to start a process with a strategy, rules and additional arguments. """ if self._upcheck(): args = arg.split() if len(args) < 3: self.ctl.output('ERROR: start_process_args requires a strategy, ' 'a program name and extra arguments') self.help_start_process_args() return strategy = StartingStrategies._from_string(args[0]) if strategy is None: self.ctl.output('ERROR: unknown strategy for start_process_args.' ' use one of {}'.format(StartingStrategies._strings())) self.help_start_process_args() return namespec = args[1] try: result = self.supvisors().start_process(strategy, namespec, ' '.join(args[2:])) except xmlrpclib.Fault, e: self.ctl.output('{}: ERROR ({})'.format(namespec, e.faultString)) else: self.ctl.output('{} started: {}'.format(namespec, result))