Пример #1
0
    def __init__(self, cfg, db):
        self.client = DispatcherNodeClient(cfg.getMessageBusHost(),
                                           cfg.messageBusPort, cfg, self)
        server.Server.__init__(self, self.client.getLogger())
        subscriberLog = logger.Logger('subscriber', cfg.getSubscriberLogPath())

        # In multinode rMake, publishing events to external subscribers
        # is done by a process forked from the dispatcher (since the
        # dispatcher gets all events anyway) instead of passing them
        # back to the rMake XMLRPC front end.
        self._publisher = publish._RmakeServerPublisher(
            subscriberLog, db, self._fork)
        # detaile data about the nodes is stored in the NodeList.
        self._nodes = NodeList(db, self._logger)

        # commands that haven't been assigned to a node.
        self._queuedCommands = []
        self._queuedCommandsById = {}
        self.db = db
Пример #2
0
    def __init__(self, cfg, db):
        self.client = DispatcherNodeClient(cfg.getMessageBusHost(),
                cfg.messageBusPort, cfg, self)
        server.Server.__init__(self, self.client.getLogger())
        subscriberLog = logger.Logger('subscriber', cfg.getSubscriberLogPath())

        # In multinode rMake, publishing events to external subscribers
        # is done by a process forked from the dispatcher (since the
        # dispatcher gets all events anyway) instead of passing them
        # back to the rMake XMLRPC front end.
        self._publisher = publish._RmakeServerPublisher(subscriberLog,
                                                        db, self._fork)
        # detaile data about the nodes is stored in the NodeList.
        self._nodes = NodeList(db, self._logger)

        # commands that haven't been assigned to a node.
        self._queuedCommands = []
        self._queuedCommandsById = {}
        self.db = db
Пример #3
0
    def __init__(self,
                 uri,
                 cfg,
                 repositoryPid=None,
                 proxyPid=None,
                 pluginMgr=None,
                 quiet=False):
        util.mkdirChain(cfg.logDir)
        logPath = cfg.logDir + '/rmake.log'
        rpcPath = cfg.logDir + '/xmlrpc.log'
        serverLogger = ServerLogger()
        serverLogger.disableRPCConsole()
        serverLogger.logToFile(logPath)
        serverLogger.logRPCToFile(rpcPath)
        if quiet:
            serverLogger.setQuietMode()
        else:
            if cfg.verbose:
                logLevel = logging.DEBUG
            else:
                logLevel = logging.INFO
            serverLogger.enableConsole(logLevel)
        serverLogger.info(
            '*** Started rMake Server at pid %s (serving at %s)' %
            (os.getpid(), uri))
        try:
            self._initialized = False
            self.db = None

            # forked jobs that are currently active
            self._buildPids = {}

            self.uri = uri
            self.cfg = cfg
            self.repositoryPid = repositoryPid
            self.proxyPid = proxyPid
            apirpc.XMLApiServer.__init__(
                self,
                uri,
                logger=serverLogger,
                forkByDefault=True,
                sslCertificate=cfg.getSslCertificatePath(),
                caCertificate=cfg.getCACertificatePath())
            self._setUpInternalUser()
            self.db = database.Database(cfg.getDbPath(),
                                        cfg.getDbContentsPath())
            self.auth = auth.AuthenticationManager(cfg.getAuthUrl(), self.db)

            if pluginMgr is None:
                pluginMgr = plugins.PluginManager([])
            self.plugins = pluginMgr

            # any jobs that were running before are not running now
            subscriberLog = logger.Logger('susbscriber',
                                          self.cfg.getSubscriberLogPath())
            self._publisher = publish._RmakeServerPublisher(
                subscriberLog, self.db, self._fork)
            self.worker = worker.Worker(self.cfg, self._logger)
            dbLogger = subscriber._JobDbLogger(self.db)
            # note - it's important that the db logger
            # comes first, before the general publisher,
            # so that whatever published is actually
            # recorded in the DB.
            self._subscribers = [dbLogger]
            if self.uri:
                s = subscriber._RmakeServerPublisherProxy(self.uri)
            else:
                # testsuite path - external subscribers also go through
                # internal interface when the server is not run as a separate
                # process.
                s = subscriber._RmakeServerPublisherProxy(ShimAddress(self))
            self._subscribers.append(s)

            self._internalSubscribers = [dbLogger]
            s = subscriber._RmakeServerPublisherProxy(ShimAddress(self))
            self._internalSubscribers.append(s)
            self.plugins.callServerHook('server_postInit', self)
        except errors.uncatchableExceptions:
            raise
        except Exception, err:
            self.error('Error initializing rMake Server:\n  %s\n%s', err,
                       traceback.format_exc())
            self._try('halt', self._shutDown)
            raise
Пример #4
0
    def __init__(self, uri, cfg, repositoryPid=None, proxyPid=None,
                 pluginMgr=None, quiet=False):
        util.mkdirChain(cfg.logDir)
        logPath = cfg.logDir + '/rmake.log'
        rpcPath = cfg.logDir + '/xmlrpc.log'
        serverLogger = ServerLogger()
        serverLogger.disableRPCConsole()
        serverLogger.logToFile(logPath)
        serverLogger.logRPCToFile(rpcPath)
        if quiet:
            serverLogger.setQuietMode()
        else:
            if cfg.verbose:
                logLevel = logging.DEBUG
            else:
                logLevel = logging.INFO
            serverLogger.enableConsole(logLevel)
        serverLogger.info('*** Started rMake Server at pid %s (serving at %s)' % (os.getpid(), uri))
        try:
            self._initialized = False
            self.db = None

            # forked jobs that are currently active
            self._buildPids = {}

            self.uri = uri
            self.cfg = cfg
            self.repositoryPid = repositoryPid
            self.proxyPid = proxyPid
            apirpc.XMLApiServer.__init__(self, uri, logger=serverLogger,
                                 forkByDefault = True,
                                 sslCertificate=cfg.getSslCertificatePath(),
                                 caCertificate=cfg.getCACertificatePath())
            self._setUpInternalUser()
            self.db = database.Database(cfg.getDbPath(),
                                        cfg.getDbContentsPath())
            self.auth = auth.AuthenticationManager(cfg.getAuthUrl(), self.db)

            if pluginMgr is None:
                pluginMgr = plugins.PluginManager([])
            self.plugins = pluginMgr

            # any jobs that were running before are not running now
            subscriberLog = logger.Logger('susbscriber',
                                          self.cfg.getSubscriberLogPath())
            self._publisher = publish._RmakeServerPublisher(subscriberLog,
                                                            self.db,
                                                            self._fork)
            self.worker = worker.Worker(self.cfg, self._logger)
            dbLogger = subscriber._JobDbLogger(self.db)
            # note - it's important that the db logger
            # comes first, before the general publisher,
            # so that whatever published is actually 
            # recorded in the DB.
            self._subscribers = [dbLogger]
            if self.uri:
                s = subscriber._RmakeServerPublisherProxy(self.uri)
            else:
                # testsuite path - external subscribers also go through
                # internal interface when the server is not run as a separate
                # process.
                s = subscriber._RmakeServerPublisherProxy(ShimAddress(self))
            self._subscribers.append(s)

            self._internalSubscribers = [dbLogger]
            s = subscriber._RmakeServerPublisherProxy(ShimAddress(self))
            self._internalSubscribers.append(s)
            self.plugins.callServerHook('server_postInit', self)
        except errors.uncatchableExceptions:
            raise
        except Exception, err:
            self.error('Error initializing rMake Server:\n  %s\n%s', err,
                        traceback.format_exc())
            self._try('halt', self._shutDown)
            raise