def _start(self): fmt = log.UtcFormatter('%(asctime)s %(name)s n %(message)s') if self._opts.foreground: # send logger output to console ch = logging.StreamHandler(sys.stderr) ch.setFormatter(fmt) ch.setLevel(logging.DEBUG) self._logger.addHandler(ch) self._logPath = '/dev/null' self._logFile = None if self._logFname is not None: logPathTemplate = os.path.join(self._logDir, self._logFname) try: self._logPath, self._logFile = (log.openLogFromTemplate( 'pyraptord', logPathTemplate, {})) except Exception as e: # pylint: disable=W0702 import traceback traceback.print_exc() self._logger.error('could not open log file %s!', logPathTemplate) if self._logFile is not None: # send logger output to file lh = logging.StreamHandler(self._logFile) lh.setFormatter(fmt) lh.setLevel(logging.DEBUG) self._logger.addHandler(lh) self._logger.debug('installing signal handlers') for sig in self._getSignalsToHandle(): signal.signal(sig, self._handleSignal) gevent.spawn(self._disableGeventDefaultSigintHandler) # load ports config self._ports = loadConfig(self._config.PORTS) self._port = self._ports[self._name].rpc if not self._opts.foreground: self._logger.debug('daemonizing') daemonize.daemonize('pyraptord', self._logFile, detachTty=not self._opts.noFork) # start startup services if 'startup' in self._config.GROUPS: startupGroup = self._config.GROUPS.startup self._logger.debug('startup group: %s', startupGroup) for svcName in startupGroup: self.startService(svcName) else: self._logger.debug('no group named "startup"') self._jobs.append(gevent.spawn(self._cleanupChildren))
def _start(self): fmt = log.UtcFormatter('%(asctime)s %(name)s n %(message)s') if self._opts.foreground: # send logger output to console ch = logging.StreamHandler(sys.stderr) ch.setFormatter(fmt) ch.setLevel(logging.DEBUG) self._logger.addHandler(ch) self._logPath = '/dev/null' self._logFile = None if self._logFname is not None: logPathTemplate = os.path.join(self._logDir, self._logFname) try: self._logPath, self._logFile = (log.openLogFromTemplate ('pyraptord', logPathTemplate, {})) except Exception as e: # pylint: disable=W0702 import traceback traceback.print_exc() self._logger.error('could not open log file %s!', logPathTemplate) if self._logFile is not None: # send logger output to file lh = logging.StreamHandler(self._logFile) lh.setFormatter(fmt) lh.setLevel(logging.DEBUG) self._logger.addHandler(lh) self._logger.debug('installing signal handlers') for sig in self._getSignalsToHandle(): signal.signal(sig, self._handleSignal) gevent.spawn(self._disableGeventDefaultSigintHandler) # load ports config self._ports = loadConfig(self._config.PORTS) self._port = self._ports[self._name].rpc if not self._opts.foreground: self._logger.debug('daemonizing') daemonize.daemonize('pyraptord', self._logFile, detachTty=not self._opts.noFork) # start startup services if 'startup' in self._config.GROUPS: startupGroup = self._config.GROUPS.startup self._logger.debug('startup group: %s', startupGroup) for svcName in startupGroup: self.startService(svcName) else: self._logger.debug('no group named "startup"') self._jobs.append(gevent.spawn(self._cleanupChildren))
def loadConfig(self, path=None): """ Load a new config file from *path* (defaults to the previous config file). Note: you can add or modify services by loading a new config, but you must restart pyraptord if you want to remove unwanted services or change global settings such as the pyraptord zerorpc endpoint. """ self._logger.debug('received: loadConfig %s', path) if path is not None: self._configPath = os.path.abspath(path) newConfig = loadConfig(self._configPath) for k, v in newConfig.iteritems(): if k in self._config and isinstance(v, dict): self._config[k].update(v) else: self._config[k] = v self._logger.debug('loaded new config %s', self._configPath)
def loadConfig(self, path=None): """ Load a new config file from *path* (defaults to the previous config file). Note: you can add or modify services by loading a new config, but you must restart pyraptord if you want to remove unwanted services or change global settings such as the pyraptord zerorpc endpoint. """ self._logger.debug('received: loadConfig %s', path) if path is not None: self._configPath = os.path.abspath(path) newConfig = loadConfig(self._configPath) for k, v in newConfig.iteritems(): if k in self._config and isinstance(v, dict): self._config[k].update(v) else: self._config[k] = v self._logger.debug('loaded new config %s', self._configPath)
def __init__(self, opts): self._opts = opts self._configPath = opts.config self._config = loadConfig(self._configPath) self._name = opts.name self._logDir = self._config.get('LOG_DIR', '/tmp/pyraptord/logs') self._logFname = self._config.get('LOG_FILE', 'pyraptord_${unique}.txt') self._pidFile = self._config.get('PID_FILE', 'pyraptord_pid.txt') self._logger = logging.getLogger('pyraptord.evt') self._logger.setLevel(logging.DEBUG) self._logger.propagate = False self._quitting = False self._shutdownCmd = None self._preQuitHandler = None self._postQuitHandler = None # self._qrouter = QueueRouter() self._services = {} self._jobs = [] self._port = None self._ports = None self._logPath = None self._logFile = None
def __init__(self, opts): self._opts = opts self._configPath = opts.config self._config = loadConfig(self._configPath) self._name = opts.name self._logDir = self._config.get('LOG_DIR', '/tmp/pyraptord/logs') self._logFname = self._config.get('LOG_FILE', 'pyraptord_${unique}.txt') self._pidFile = self._config.get('PID_FILE', 'pyraptord_pid.txt') self._logger = logging.getLogger('pyraptord.evt') self._logger.setLevel(logging.DEBUG) self._logger.propagate = False self._quitting = False self._shutdownCmd = None self._preQuitHandler = None self._postQuitHandler = None # self._qrouter = QueueRouter() self._services = {} self._jobs = [] self._port = None self._ports = None self._logPath = None self._logFile = None
def __init__(self, configPath): self._config = loadConfig(configPath) self._ports = loadConfig(self._config.PORTS)
def __init__(self, configPath): self._config = loadConfig(configPath) self._ports = loadConfig(self._config.PORTS)