def main(prod, start_syncback, enable_tracer, config, port, enable_profiler): """ Launch the Nylas API service. """ level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL")) configure_logging(log_level=level) maybe_enable_rollbar() if config is not None: config_path = os.path.abspath(config) load_overrides(config_path) if prod: start(port, start_syncback, enable_tracer, enable_profiler) else: preflight() from werkzeug.serving import run_with_reloader run_with_reloader(lambda: start(port, start_syncback, enable_tracer, enable_profiler))
def main(prod, config, process_num, syncback_id, enable_tracer, enable_profiler): """ Launch the actions syncback service. """ setproctitle("syncback-{}".format(process_num)) maybe_enable_rollbar() print("Python", sys.version, file=sys.stderr) if config is not None: config_path = os.path.abspath(config) load_overrides(config_path) level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL")) configure_logging(log_level=level) reconfigure_logging() total_processes = int(os.environ.get("SYNCBACK_PROCESSES", 1)) def start(): # Start the syncback service, and just hang out forever syncback = SyncbackService(syncback_id, process_num, total_processes) if enable_profiler: inbox_config["DEBUG_PROFILING_ON"] = True port = 16384 + process_num enable_profiler_api = inbox_config.get("DEBUG_PROFILING_ON") frontend = SyncbackHTTPFrontend(port, enable_tracer, enable_profiler_api) frontend.start() syncback.start() syncback.join() if prod: start() else: preflight() from werkzeug.serving import run_with_reloader run_with_reloader(start)
def main(prod, config): """ Launch the contact search index service. """ level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL")) configure_logging(log_level=level) maybe_enable_rollbar() if config is not None: from inbox.util.startup import load_overrides config_path = os.path.abspath(config) load_overrides(config_path) # import here to make sure config overrides are loaded from inbox.transactions.search import ContactSearchIndexService if not prod: preflight() contact_search_indexer = ContactSearchIndexService() contact_search_indexer.start() contact_search_indexer.join()
from datetime import datetime, timedelta import pytest import inbox.heartbeat.config as heartbeat_config from inbox.config import config from inbox.heartbeat.config import ALIVE_EXPIRY from inbox.heartbeat.status import clear_heartbeat_status, get_ping_status from inbox.heartbeat.store import ( HeartbeatStatusKey, HeartbeatStatusProxy, HeartbeatStore, ) from inbox.logging import configure_logging configure_logging(config.get("LOGLEVEL")) from mockredis import MockRedis # Note that all Redis commands are mocked via mockredis in conftest.py. def proxy_for( account_id, folder_id, email="*****@*****.**", provider="gmail", device_id=0 ): return HeartbeatStatusProxy( account_id=account_id, folder_id=folder_id, folder_name="Inbox", email_address=email, provider_name=provider,
concurrently.) Currently, this script populates queues for all configured zones. It could be modified so that different zones are populated independently, if needed. """ import gevent import gevent.monkey gevent.monkey.patch_all() from setproctitle import setproctitle from inbox.config import config from inbox.error_handling import maybe_enable_rollbar from inbox.logging import configure_logging from inbox.scheduling.queue import QueuePopulator configure_logging() def main(): maybe_enable_rollbar() setproctitle("scheduler") zones = {h.get("ZONE") for h in config["DATABASE_HOSTS"]} threads = [] for zone in zones: populator = QueuePopulator(zone) threads.append(gevent.spawn(populator.run)) gevent.joinall(threads)
from gevent import monkey monkey.patch_all() import logging import sys import click import gevent from inbox.config import config from inbox.error_handling import maybe_enable_rollbar from inbox.logging import configure_logging, get_logger from inbox.models.util import purge_transactions configure_logging(logging.INFO) log = get_logger() @click.command() @click.option("--days-ago", type=int, default=60) @click.option("--limit", type=int, default=1000) @click.option("--throttle", is_flag=True) @click.option("--dry-run", is_flag=True) def run(days_ago, limit, throttle, dry_run): maybe_enable_rollbar() print("Python", sys.version, file=sys.stderr) pool = []
def main(prod, enable_tracer, enable_profiler, config, process_num, exit_after): """ Launch the Nylas sync service. """ level = os.environ.get("LOGLEVEL", inbox_config.get("LOGLEVEL")) configure_logging(log_level=level) reconfigure_logging() maybe_enable_rollbar() if config is not None: from inbox.util.startup import load_overrides config_path = os.path.abspath(config) load_overrides(config_path) if not prod: preflight() total_processes = int(os.environ.get("MAILSYNC_PROCESSES", 1)) setproctitle.setproctitle("sync-engine-{}".format(process_num)) log = get_logger() log.info( "start", components=["mail sync", "contact sync", "calendar sync"], host=platform.node(), process_num=process_num, total_processes=total_processes, recursion_limit=sys.getrecursionlimit(), ) print(banner, file=sys.stderr) print(file=sys.stderr) print("Python", sys.version, file=sys.stderr) if enable_profiler: inbox_config["DEBUG_PROFILING_ON"] = True port = 16384 + process_num enable_profiler_api = inbox_config.get("DEBUG_PROFILING_ON") process_identifier = "{}:{}".format(platform.node(), process_num) if exit_after: exit_after = exit_after.split(":") exit_after_min, exit_after_max = int(exit_after[0]), int(exit_after[1]) else: exit_after_min, exit_after_max = None, None sync_service = SyncService( process_identifier, process_num, exit_after_min=exit_after_min, exit_after_max=exit_after_max, ) signal.signal(signal.SIGTERM, sync_service.stop) signal.signal(signal.SIGINT, sync_service.stop) http_frontend = SyncHTTPFrontend(sync_service, port, enable_tracer, enable_profiler_api) sync_service.register_pending_avgs_provider(http_frontend) http_frontend.start() sync_service.run() print("\033[94mNylas Sync Engine exiting...\033[0m", file=sys.stderr)
def __init__(self, cfg): gunicorn.glogging.Logger.__init__(self, cfg) configure_logging(log_level=LOGLEVEL) self.error_log = log