Example #1
0
    def __init__(self, cfg, serverLogger):
        self.nodeClient = None
        self.cfg = cfg
        apirpc.XMLApiServer.__init__(self, uri=None, logger=serverLogger)

        self.db = database.Database(cfg.getDbPath(), cfg.getDbContentsPath(),
                memCache=cfg.memCache)
        self.auth = auth.AuthenticationManager(cfg.getAuthUrl(), self.db)
        self.nodeClient = mn_subscriber.RPCNodeClient(self.cfg, self)

        self.worker = workerproxy.WorkerProxy(self.cfg, self.nodeClient,
                self._logger)
        dbLogger = subscriber._JobDbLogger(self.db)
        nodesub = mn_subscriber._RmakeBusPublisher(self.nodeClient)
        # 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, nodesub]
Example #2
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
Example #3
0
 def subscribeToJob(self, job):
     """ 
         Watches updates to this job object and will record them
         in the db.
     """
     _JobDbLogger(self).attach(job)
Example #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
Example #5
0
 def _connectDatabase(self):
     self.db = database.Database(self.cfg.getDbPath(),
             self.cfg.getDbContentsPath(),
             memCache=self.cfg.memCache)
     self._subscribers.append(build_subscriber._JobDbLogger(self.db))
Example #6
0
 def subscribeToJob(self, job):
     """ 
         Watches updates to this job object and will record them
         in the db.
     """
     _JobDbLogger(self).attach(job)