Example #1
0
 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 = DeploymentStrategies._from_string(args[0])
         if strategy is None:
             self.ctl.output(
                 'ERROR: unknown strategy for start_process_args.'
                 ' use one of {}'.format(DeploymentStrategies._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))
Example #2
0
 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 = DeploymentStrategies._from_string(args[0])
         if strategy is None:
             self.ctl.output(
                 'ERROR: unknown strategy for restart_application.'
                 ' use one of {}'.format(DeploymentStrategies._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))
Example #3
0
 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 = DeploymentStrategies._from_string(args[0])
         if strategy is None:
             self.ctl.output(
                 'ERROR: unknown strategy for start_process. use one of {}'.
                 format(DeploymentStrategies._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))
Example #4
0
 def to_deployment_strategy(value):
     """ Convert a string into a DeploymentStrategies enum. """
     strategy = DeploymentStrategies._from_string(value)
     if strategy is None:
         raise ValueError(
             'invalid value for deployment_strategy: {}. expected in {}'.
             format(value, DeploymentStrategies._strings()))
     return strategy
Example #5
0
 def do_start_application(self, arg):
     if self._upcheck():
         args = arg.split()
         if len(args) < 2:
             self.ctl.output('ERROR: start_application requires a strategy and an application name')
             self.help_start_application()
             return
         strategy = DeploymentStrategies._from_string(args[0])
         if strategy is None:
             self.ctl.output('ERROR: unknown strategy for start_application. use one of {}'.format(DeploymentStrategies._strings()))
             self.help_start_application()
             return
         applications = args[1:]
         if not applications or "all" in applications:
             applications = [application_info['application_name'] for application_info in self.supvisors().get_all_applications_info()]
         for application in applications:
             try:
                 result = self.supvisors().start_application(strategy, application)
             except xmlrpclib.Fault, e:
                 self.ctl.output('{}: ERROR ({})'.format(application, e.faultString))
             else:
                 self.ctl.output('{} started: {}'.format(application, result))