コード例 #1
0
def main(work_dir):
    startup_time = time.time()

    glideinFrontendConfig.frontendConfig.frontend_descript_file = os.path.join(work_dir, glideinFrontendConfig.frontendConfig.frontend_descript_file)
    frontendDescript = glideinFrontendConfig.FrontendDescript(work_dir)

    # the log dir is shared between the frontend main and the groups, so use a subdir
    logSupport.log_dir = os.path.join(frontendDescript.data['LogDir'], "frontend")
    # Configure the process to use the proper LogDir as soon as you get the info
    logSupport.add_glideinlog_handler("frontend", logSupport.log_dir,
                                      int(float(frontendDescript.data['LogRetentionMaxDays'])),
                                      int(float(frontendDescript.data['LogRetentionMaxMBs'])))
    logSupport.log = logging.getLogger("frontend")
    logSupport.log.debug("Logging initialized")
    logSupport.log.debug("Frontend startup time: %s" % str(startup_time))

    try:
        cleanup_environ()
        # we use a dedicated config... ignore the system-wide
        os.environ['CONDOR_CONFIG'] = frontendDescript.data['CondorConfig']

        sleep_time = int(frontendDescript.data['LoopDelay'])
        advertize_rate = int(frontendDescript.data['AdvertiseDelay'])
        restart_attempts = int(frontendDescript.data['RestartAttempts'])
        restart_interval = int(frontendDescript.data['RestartInterval'])

        groups = string.split(frontendDescript.data['Groups'], ',')
        groups.sort()

        glideinFrontendMonitorAggregator.monitorAggregatorConfig.config_frontend(os.path.join(work_dir, "monitor"), groups)
    except:
        tb = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1],
                                        sys.exc_info()[2])
        logSupport.log.warning("Exception occurred: %s" % tb)
        raise

    # create lock file
    pid_obj = glideinFrontendPidLib.FrontendPidSupport(work_dir)

    # start
    pid_obj.register()
    try:
        try:
            spawn(sleep_time, advertize_rate, work_dir,
                  frontendDescript, groups, restart_attempts, restart_interval)
        except KeyboardInterrupt, e:
            logSupport.log.info("Received signal...exit")
        except:
            tb = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1],
                                            sys.exc_info()[2])
            logSupport.log.warning("Exception occurred: %s" % tb)
コード例 #2
0
            # Ignore all errors
            pass
            

############################################################
def main(parent_pid, work_dir, group_name):
    startup_time = time.time()

    elementDescript = glideinFrontendConfig.ElementMergedDescript(work_dir, group_name)

    # the log dir is shared between the frontend main and the groups, so use a subdir
    logSupport.log_dir = os.path.join(elementDescript.frontend_data['LogDir'], "group_%s" % group_name)
    # Set the Log directory
    # Configure the process to use the proper LogDir as soon as you get the info
    logSupport.add_glideinlog_handler("group_%s" % group_name, logSupport.log_dir,
                                      int(float(elementDescript.frontend_data['LogRetentionMaxDays'])),
                                      int(float(elementDescript.frontend_data['LogRetentionMaxMBs'])))
    logSupport.log = logging.getLogger("group_%s" % group_name)
    logSupport.log.debug("Logging initialized")
    logSupport.log.debug("Frontend Element startup time: %s" % str(startup_time))

    paramsDescript = glideinFrontendConfig.ParamsDescript(work_dir, group_name)
    signatureDescript = glideinFrontendConfig.GroupSignatureDescript(work_dir, group_name)

    glideinFrontendMonitoring.monitoringConfig.monitor_dir = os.path.join(work_dir, "monitor/group_%s" % group_name)

    glideinFrontendInterface.frontendConfig.advertise_use_tcp = (elementDescript.frontend_data['AdvertiseWithTCP'] in ('True', '1'))
    glideinFrontendInterface.frontendConfig.advertise_use_multi = (elementDescript.frontend_data['AdvertiseWithMultiple'] in ('True', '1'))

    try:
        dir = os.path.dirname(os.path.dirname(sys.argv[0]))
コード例 #3
0
ファイル: glideFactory.py プロジェクト: klarson1/master_test
def main(startup_dir):
    """
    Reads in the configuration file and starts up the factory
    
    @type startup_dir: String 
    @param startup_dir: Path to glideinsubmit directory
    """
    
    startup_time=time.time()

    # force integrity checks on all the operations
    # I need integrity checks also on reads, as I depend on them
    os.environ['_CONDOR_SEC_DEFAULT_INTEGRITY'] = 'REQUIRED'
    os.environ['_CONDOR_SEC_CLIENT_INTEGRITY'] = 'REQUIRED'
    os.environ['_CONDOR_SEC_READ_INTEGRITY'] = 'REQUIRED'
    os.environ['_CONDOR_SEC_WRITE_INTEGRITY'] = 'REQUIRED'

    glideFactoryConfig.factoryConfig.glidein_descript_file = os.path.join(startup_dir, glideFactoryConfig.factoryConfig.glidein_descript_file)
    glideinDescript = glideFactoryConfig.GlideinDescript()
    frontendDescript = glideFactoryConfig.FrontendDescript()

    # Setup the glideFactoryLib.factoryConfig so that we can process the globals classads
    glideFactoryLib.factoryConfig.config_whoamI(glideinDescript.data['FactoryName'], glideinDescript.data['GlideinName'])
    glideFactoryLib.factoryConfig.config_dirs(startup_dir, glideinDescript.data['LogDir'],
                                              glideinDescript.data['ClientLogBaseDir'],
                                              glideinDescript.data['ClientProxiesBaseDir'])

    write_descript(glideinDescript, frontendDescript, os.path.join(startup_dir, 'monitor/'))

    # Set the Log directory
    logSupport.log_dir = os.path.join(glideinDescript.data['LogDir'], "factory")

    # Configure the process to use the proper LogDir as soon as you get the info
    logSupport.add_glideinlog_handler("factory", logSupport.log_dir,
                                      int(float(glideinDescript.data['LogRetentionMaxDays'])),
                                      int(float(glideinDescript.data['LogRetentionMaxMBs'])))
    logSupport.log = logging.getLogger("factory")
    logSupport.log.debug("Logging initialized")
    logSupport.log.debug("Daemon start time: %s" % str(startup_time))

    try:
        os.chdir(startup_dir)
    except:
        tb = traceback.format_exception(sys.exc_info()[0],sys.exc_info()[1],
                                        sys.exc_info()[2])
        logSupport.log.warning("Unable to change to startup_dir %s: %s" % (startup_dir,tb))
        raise

    try:
        
        if (is_file_old(glideinDescript.default_rsakey_fname, 
                        int(glideinDescript.data['OldPubKeyGraceTime']))):
            # First back and load any existing key
            logSupport.log.info("Backing up and loading old key")
            glideinDescript.backup_and_load_old_key()
            # Create a new key for this run
            logSupport.log.info("Recreating and loading new key")
            glideinDescript.load_pub_key(recreate=True)
        else:
            # Key is recent enough. Just reuse them.
            logSupport.log.info("Key is recent enough")
            logSupport.log.info("Reusing key for this run")
            glideinDescript.load_pub_key(recreate=False)
            logSupport.log.info("Loading old key")
            glideinDescript.load_old_rsa_key()
        
        glideFactoryMonitorAggregator.glideFactoryMonitoring.monitoringConfig.my_name = "%s@%s" % (glideinDescript.data['GlideinName'], glideinDescript.data['FactoryName'])

        # check that the GSI environment is properly set
        if not os.environ.has_key('X509_CERT_DIR'):
            logSupport.log.warning("Environment variable X509_CERT_DIR not set. Need X509_CERT_DIR to work!")
            raise RuntimeError, "Need X509_CERT_DIR to work!"

        glideFactoryInterface.factoryConfig.advertise_use_tcp = (glideinDescript.data['AdvertiseWithTCP'] in ('True', '1'))
        glideFactoryInterface.factoryConfig.advertise_use_multi = (glideinDescript.data['AdvertiseWithMultiple'] in ('True', '1'))
        sleep_time = int(glideinDescript.data['LoopDelay'])
        advertize_rate = int(glideinDescript.data['AdvertiseDelay'])
        restart_attempts = int(glideinDescript.data['RestartAttempts'])
        restart_interval = int(glideinDescript.data['RestartInterval'])

        entries = glideinDescript.data['Entries'].split(',')
        entries.sort()

        glideFactoryMonitorAggregator.monitorAggregatorConfig.config_factory(os.path.join(startup_dir, "monitor"), entries)
    except:
        tb = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1],
                                        sys.exc_info()[2])
        logSupport.log.warning("Exception occurred: %s" % tb)
        raise

    # create lock file
    pid_obj = glideFactoryPidLib.FactoryPidSupport(startup_dir)

    # start
    pid_obj.register()
    try:
        try:
            spawn(sleep_time, advertize_rate, startup_dir,
                  glideinDescript, frontendDescript, entries, restart_attempts, restart_interval)
        except KeyboardInterrupt, e:
            raise e
        except:
            tb = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2])
            logSupport.log.warning("Exception occurred: %s" % tb)