def testReloading(self): self.assertEquals(config.HTTPPort, 0) config.load(self.testConfig) self.assertEquals(config.HTTPPort, 8008) writePlist({}, self.testConfig) self._reloadingValue = None config.addPostUpdateHooks([self._myUpdateHook]) config.reload() # Make sure reloading=True was passed to the update hooks self.assertTrue(self._reloadingValue) self.assertEquals(config.HTTPPort, 0)
def testReloading(self): self.assertEquals(config.HTTPPort, 0) config.load(self.testConfig) self.assertEquals(config.HTTPPort, 8008) writePlist({}, self.testConfig) self._reloadingValue = None config.addPostUpdateHooks([self._myUpdateHook]) config.reload() # Make sure reloading=True was passed to the update hooks self.assertTrue(self._reloadingValue) self.assertEquals(config.HTTPPort, 0)
options.parseOptions(argv[1:]) except UsageError, e: usage(e) try: output = options.openOutput() except IOError, e: stderr.write("Unable to open output file for writing: %s\n" % (e)) sys.exit(1) if options.merge: def setMerge(data): data.MergeUpgrades = True config.addPostUpdateHooks([setMerge]) def makeService(store): return UpgraderService(store, options, output, reactor, config) def onlyUpgradeEvents(eventDict): text = formatEvent(eventDict) output.write( formatTime(eventDict.get("log_time", time.time())) + " " + text + "\n") output.flush() if not options["status"] and not options["check"]: # When doing an upgrade always send L{LogLevel.warn} logging to the tool output log.observer.addObserver( FilteringLogObserver(onlyUpgradeEvents, [
def makeService_Slave(self, options): # # Change default log level to "info" as its useful to have # that during startup # oldLogLevel = logLevelForNamespace(None) setLogLevelForNamespace(None, "info") additional = [] if config.Scheduling.iMIP.Enabled: additional.append(("inbox", IMIPReplyInboxResource, [], "basic")) rootResource = getRootResource(config, additional) # # Configure the service # self.log_info("Setting up service") if config.ProcessType == "Slave": if config.ControlSocket: mode = "AF_UNIX" id = config.ControlSocket self.log_info("Logging via AF_UNIX: %s" % (id,)) else: mode = "IF_INET" id = int(config.ControlPort) self.log_info("Logging via AF_INET: %d" % (id,)) logObserver = AMPCommonAccessLoggingObserver(mode, id) elif config.ProcessType == "Single": # Make sure no old socket files are lying around. self.deleteStaleSocketFiles() logObserver = RotatingFileAccessLoggingObserver( config.AccessLogFile, ) self.log_info("Configuring access log observer: %s" % (logObserver,)) service = CalDAVService(logObserver) site = Site(rootResource) httpFactory = LimitingHTTPFactory( site, maxRequests=config.MaxRequests, maxAccepts=config.MaxAccepts, betweenRequestsTimeOut=config.IdleConnectionTimeOut, vary=True, ) if config.RedirectHTTPToHTTPS: redirectFactory = LimitingHTTPFactory( SSLRedirectRequest, maxRequests=config.MaxRequests, maxAccepts=config.MaxAccepts, betweenRequestsTimeOut=config.IdleConnectionTimeOut, vary=True, ) def updateFactory(configDict): httpFactory.maxRequests = configDict.MaxRequests httpFactory.maxAccepts = configDict.MaxAccepts if config.RedirectHTTPToHTTPS: redirectFactory.maxRequests = configDict.MaxRequests redirectFactory.maxAccepts = configDict.MaxAccepts config.addPostUpdateHooks((updateFactory,)) if config.InheritFDs or config.InheritSSLFDs: # Inherit sockets to call accept() on them individually. for fd in config.InheritSSLFDs: fd = int(fd) try: contextFactory = self.createContextFactory() except SSLError, e: log.error("Unable to set up SSL context factory: %s" % (e,)) else: MaxAcceptSSLServer( fd, httpFactory, contextFactory, backlog=config.ListenBacklog, inherit=True ).setServiceParent(service) for fd in config.InheritFDs: fd = int(fd) if config.RedirectHTTPToHTTPS: self.log_info("Redirecting to HTTPS port %s" % (config.SSLPort,)) useFactory = redirectFactory else: useFactory = httpFactory MaxAcceptTCPServer( fd, useFactory, backlog=config.ListenBacklog, inherit=True ).setServiceParent(service)
options = UpgradeOptions() try: options.parseOptions(argv[1:]) except UsageError, e: usage(e) try: output = options.openOutput() except IOError, e: stderr.write("Unable to open output file for writing: %s\n" % (e)) sys.exit(1) if options.merge: def setMerge(data): data.MergeUpgrades = True config.addPostUpdateHooks([setMerge]) def makeService(store): return UpgraderService(store, options, output, reactor, config) def onlyUpgradeEvents(eventDict): text = formatEvent(eventDict) output.write(logDateString() + " " + text + "\n") output.flush() if not options["status"]: log.publisher.levels.setLogLevelForNamespace(None, LogLevel.debug) addObserver(onlyUpgradeEvents)
if oldKey in configDict and newKey in configDict: raise ConfigurationError( "Both %r and %r options are specified; use the %r option only." % (oldKey, newKey, newKey) ) def renamed(oldKey, newKey): deprecated(oldKey, newKey) cleanDict[newKey] = configDict[oldKey] del cleanDict[oldKey] renamedOptions = { # "BindAddress": "BindAddresses", } for key in configDict: if key in defaultDict: continue elif key in renamedOptions: renamed(key, renamedOptions[key]) else: unknown(key,) return cleanDict config.setProvider(PListConfigProvider(DEFAULT_CONFIG)) config.addPreUpdateHooks(PRE_UPDATE_HOOKS) config.addPostUpdateHooks(POST_UPDATE_HOOKS)