def _start_web_server(cls): if not MailpileSeleniumTest.http_worker: (mp, session, config, _) = get_shared_mailpile() sspec = MailpileSeleniumTest._get_mailpile_sspec() MailpileSeleniumTest.http_worker = config.http_worker = HttpWorker( session, sspec) config.http_worker.start()
def _start_web_server(cls): mp = get_shared_mailpile() session = mp._session config = mp._config sspec = cls._get_mailpile_sspec() cls.http_worker = config.http_worker = HttpWorker(session, sspec) config.http_worker.start()
def prepare_workers(config, session, daemons=False): # Set globals from config first... mailpile.util.APPEND_FD_CACHE_SIZE = config.sys.fd_cache_size if not config.background: # Create a silent background session config.background = Session(config) config.background.ui = BackgroundInteraction(config) config.background.ui.block() # Start the workers if config.slow_worker == config.dumb_worker: config.slow_worker = Worker('Slow worker', session) config.slow_worker.start() if daemons and not config.cron_worker: config.cron_worker = Cron('Cron worker', session) config.cron_worker.start() # Schedule periodic rescanning, if requested. rescan_interval = config.prefs.rescan_interval if rescan_interval: def rescan(): if 'rescan' not in config._running: rsc = Rescan(session, 'rescan') rsc.serialize = False config.slow_worker.add_task(None, 'Rescan', rsc.run) config.cron_worker.add_task('rescan', rescan_interval, rescan) if daemons and not config.http_worker: # Start the HTTP worker if requested sspec = (config.sys.http_host, config.sys.http_port) if sspec[0].lower() != 'disabled' and sspec[1] >= 0: config.http_worker = HttpWorker(session, sspec) config.http_worker.start()
def _start_web_server(cls): if not MailpileSeleniumTest.http_worker: mp = get_shared_mailpile() session = mp._session config = mp._config sspec = MailpileSeleniumTest._get_mailpile_sspec() MailpileSeleniumTest.http_worker = config.http_worker = HttpWorker( session, sspec) config.http_worker.start()
def prepare_workers(config, session=None, daemons=False): # Set globals from config first... import mailpile.util # Make sure we have a silent background session if not config.background: config.background = Session(config) config.background.ui = BackgroundInteraction(config) config.background.ui.block() # Start the workers if daemons: if config.slow_worker == config.dumb_worker: config.slow_worker = Worker('Slow worker', session) config.slow_worker.start() if not config.cron_worker: config.cron_worker = Cron('Cron worker', session) config.cron_worker.start() if not config.http_worker: # Start the HTTP worker if requested sspec = (config.sys.http_host, config.sys.http_port) if sspec[0].lower() != 'disabled' and sspec[1] >= 0: config.http_worker = HttpWorker(session, sspec) config.http_worker.start() if not config.other_workers: import mailpile.plugins for worker in mailpile.plugins.WORKERS: w = worker(session) w.start() config.other_workers.append(w) # Update the cron jobs, if necessary if config.cron_worker: session = session or config.background # Schedule periodic rescanning, if requested. rescan_interval = config.prefs.rescan_interval if rescan_interval: def rescan(): if 'rescan' not in config._running: rsc = Rescan(session, 'rescan') rsc.serialize = False config.slow_worker.add_task(session, 'Rescan', rsc.run) config.cron_worker.add_task('rescan', rescan_interval, rescan) # Schedule plugin jobs import mailpile.plugins def interval(i): if isinstance(i, (str, unicode)): i = config.walk(i) return int(i) for job, (i, f) in mailpile.plugins.FAST_PERIODIC_JOBS.iteritems(): config.cron_worker.add_task(job, interval(i), lambda: f(session)) for job, (i, f) in mailpile.plugins.SLOW_PERIODIC_JOBS.iteritems(): def wrap(): config.slow_worker.add_task(session, job, lambda: f(session)) config.cron_worker.add_task(job, interval(i), wrap)