示例#1
0
def do_supervisorctl(logger, instance_root, supervisor_args, forbid_supervisord_launch=False):
    from slapos.grid.svcbackend import (launchSupervisord, _getSupervisordConfigurationFilePath)
    if forbid_supervisord_launch is False:
        launchSupervisord(instance_root=instance_root, logger=logger)
    supervisor.supervisorctl.main(
        args=['-c', _getSupervisordConfigurationFilePath(instance_root)] + supervisor_args
    )
示例#2
0
 def take_action(self, args):
     configp = self.fetch_config(args)
     instance_root = configp.get('slapos', 'instance_root')
     configuration_file = os.path.join(instance_root, 'etc', 'supervisord.conf')
     launchSupervisord(socket=os.path.join(instance_root, 'supervisord.socket'),
                       configuration_file=configuration_file,
                       logger=self.app.log)
     supervisor.supervisorctl.main(args=['-c', configuration_file] + args.supervisor_args)
示例#3
0
def supervisord(*argument_tuple):
  logger = logging.getLogger('SVCBackend')
  logger.setLevel(logging.INFO)
  handler = logging.StreamHandler()
  logger.addHandler(handler)

  option_dict, _ = getOptionDict(*argument_tuple)
  launchSupervisord(socket=option_dict['supervisord_socket'],
                    configuration_file=option_dict['supervisord_configuration_path'],
                    logger=logger)
示例#4
0
def supervisorctl(*argument_tuple):
  logger = logging.getLogger('SVCBackend')
  logger.setLevel(logging.INFO)
  handler = logging.StreamHandler()
  logger.addHandler(handler)

  option_dict, args = getOptionDict(*argument_tuple)
  import supervisor.supervisorctl
  launchSupervisord(socket=option_dict['supervisord_socket'],
                    configuration_file=option_dict['supervisord_configuration_path'],
                    logger=logger)
  supervisor.supervisorctl.main(args=['-c', option_dict['supervisord_configuration_path']] + args)
示例#5
0
 def take_action(self, args):
     configp = self.fetch_config(args)
     instance_root = configp.get('slapos', 'instance_root')
     if args.nodaemon:
       supervisord_additional_argument_list = ['--nodaemon']
     else:
       supervisord_additional_argument_list = []
     createSupervisordConfiguration(instance_root)
     launchSupervisord(
         instance_root=instance_root, logger=self.app.log,
         supervisord_additional_argument_list=supervisord_additional_argument_list
     )
示例#6
0
def do_configure(args, fetch_config_func, logger):
    """
    Generate configuration files,
    Create the instance path by running slapformat (but will crash),
    Add proxy to supervisor,
    Run supervisor, which will run the proxy,
    Run format, which will finish correctly.
    """
    slapos_node_config_path = os.path.join(
        args.slapos_configuration_directory, 'slapos.cfg')
    if os.path.exists(slapos_node_config_path):
        logger.error('A SlapOS configuration directory already exist at'
                     ' %s. Aborting.' % slapos_node_config_path)
        raise SystemExit(1)
    if not getattr(args, 'cfg', None):
        args.cfg = slapos_node_config_path
    _createConfigurationDirectory(args.slapos_configuration_directory)
    _generateSlaposNodeConfigurationFile(slapos_node_config_path, args)
    configp = fetch_config_func(args)
    conf = FormatConfig(logger=logger)
    conf.mergeConfig(args, configp)
    # The First thing we have to do here is to generate slapproxy conf
    # for supervisord, then supervisord certainly start slapproxy.
    proxy_configuration_file = _generateSlaposProxyConfigurationFile(conf)
    conf.proxy_configuration_file = proxy_configuration_file
    _addProxyToSupervisor(conf)
    # Do the rest
    slapgrid = create_slapgrid_object(conf.__dict__, logger)
    createPrivateDirectory(os.path.join(conf.slapos_buildout_directory, 'log'))
    _runFormat(conf.slapos_buildout_directory)
    slapgrid.checkEnvironmentAndCreateStructure()
    home_folder_path = os.environ['HOME']
    createPrivateDirectory("%s/.slapos" % home_folder_path)
    slapos_client_cfg_path = '%s/.slapos/slapos-client.cfg' % home_folder_path
    if not os.path.exists(slapos_client_cfg_path):
        os.symlink(slapos_node_config_path, slapos_client_cfg_path)
    launchSupervisord(instance_root=conf.instance_root, logger=logger)
    _runFormat(conf.slapos_buildout_directory)
    return 0
示例#7
0
 def _launchSupervisord(self):
   launchSupervisord(self.supervisord_socket,
                     self.supervisord_configuration_path,
                     logger=self.logger)
示例#8
0
 def _launchSupervisord(self):
   if not self.forbid_supervisord_automatic_launch:
     launchSupervisord(instance_root=self.instance_root, logger=self.logger)