예제 #1
0
파일: _base.py 프로젝트: lxndrbnsv/synapse
 def run():
     logger.info("Running")
     setup_jemalloc_stats()
     change_resource_limit(soft_file_limit)
     if gc_thresholds:
         gc.set_threshold(*gc_thresholds)
     run_command()
예제 #2
0
 def run():
     with LoggingContext("run"):
         logger.info("Running")
         change_resource_limit(config.soft_file_limit)
         if config.gc_thresholds:
             gc.set_threshold(*config.gc_thresholds)
         reactor.run()
예제 #3
0
 def run():
     with LoggingContext("run"):
         logger.info("Running")
         change_resource_limit(config.soft_file_limit)
         if config.gc_thresholds:
             gc.set_threshold(*config.gc_thresholds)
         reactor.run()
예제 #4
0
파일: _base.py 프로젝트: matrix-org/synapse
    def run():
        # make sure that we run the reactor with the sentinel log context,
        # otherwise other PreserveLoggingContext instances will get confused
        # and complain when they see the logcontext arbitrarily swapping
        # between the sentinel and `run` logcontexts.
        with PreserveLoggingContext():
            logger.info("Running")
            if cpu_affinity is not None:
                # Turn the bitmask into bits, reverse it so we go from 0 up
                mask_to_bits = bin(cpu_affinity)[2:][::-1]

                cpus = []
                cpu_num = 0

                for i in mask_to_bits:
                    if i == "1":
                        cpus.append(cpu_num)
                    cpu_num += 1

                p = psutil.Process()
                p.cpu_affinity(cpus)

            change_resource_limit(soft_file_limit)
            if gc_thresholds:
                gc.set_threshold(*gc_thresholds)
            reactor.run()
예제 #5
0
파일: _base.py 프로젝트: tangyiyong/synapse
    def run():
        # make sure that we run the reactor with the sentinel log context,
        # otherwise other PreserveLoggingContext instances will get confused
        # and complain when they see the logcontext arbitrarily swapping
        # between the sentinel and `run` logcontexts.
        with PreserveLoggingContext():
            logger.info("Running")
            if cpu_affinity is not None:
                # Turn the bitmask into bits, reverse it so we go from 0 up
                mask_to_bits = bin(cpu_affinity)[2:][::-1]

                cpus = []
                cpu_num = 0

                for i in mask_to_bits:
                    if i == "1":
                        cpus.append(cpu_num)
                    cpu_num += 1

                p = psutil.Process()
                p.cpu_affinity(cpus)

            change_resource_limit(soft_file_limit)
            if gc_thresholds:
                gc.set_threshold(*gc_thresholds)
            reactor.run()
예제 #6
0
 def in_thread():
     # Uncomment to enable tracing of log context changes.
     # sys.settrace(logcontext_tracer)
     with LoggingContext("run"):
         change_resource_limit(hs.config.soft_file_limit)
         if hs.config.gc_thresholds:
             gc.set_threshold(*hs.config.gc_thresholds)
         reactor.run()
예제 #7
0
 def in_thread():
     # Uncomment to enable tracing of log context changes.
     # sys.settrace(logcontext_tracer)
     with LoggingContext("run"):
         change_resource_limit(hs.config.soft_file_limit)
         if hs.config.gc_thresholds:
             gc.set_threshold(*hs.config.gc_thresholds)
         reactor.run()
예제 #8
0
 def run():
     # make sure that we run the reactor with the sentinel log context,
     # otherwise other PreserveLoggingContext instances will get confused
     # and complain when they see the logcontext arbitrarily swapping
     # between the sentinel and `run` logcontexts.
     with PreserveLoggingContext():
         logger.info("Running")
         change_resource_limit(config.soft_file_limit)
         if config.gc_thresholds:
             gc.set_threshold(*config.gc_thresholds)
         reactor.run()
예제 #9
0
    def in_thread():
        # Uncomment to enable tracing of log context changes.
        # sys.settrace(logcontext_tracer)

        # make sure that we run the reactor with the sentinel log context,
        # otherwise other PreserveLoggingContext instances will get confused
        # and complain when they see the logcontext arbitrarily swapping
        # between the sentinel and `run` logcontexts.
        with PreserveLoggingContext():
            change_resource_limit(hs.config.soft_file_limit)
            if hs.config.gc_thresholds:
                gc.set_threshold(*hs.config.gc_thresholds)
            reactor.run()
예제 #10
0
 def run():
     # make sure that we run the reactor with the sentinel log context,
     # otherwise other PreserveLoggingContext instances will get confused
     # and complain when they see the logcontext arbitrarily swapping
     # between the sentinel and `run` logcontexts.
     with PreserveLoggingContext():
         logger.info("Running")
         if cpu_affinity is not None:
             if not affinity:
                 quit_with_error(
                     "Missing package 'affinity' required for cpu_affinity\n"
                     "option\n\n"
                     "Install by running:\n\n"
                     "   pip install affinity\n\n")
             logger.info("Setting CPU affinity to %s" % cpu_affinity)
             affinity.set_process_affinity_mask(0, cpu_affinity)
         change_resource_limit(soft_file_limit)
         if gc_thresholds:
             gc.set_threshold(*gc_thresholds)
         reactor.run()
예제 #11
0
파일: _base.py 프로젝트: rubo77/synapse
 def run():
     # make sure that we run the reactor with the sentinel log context,
     # otherwise other PreserveLoggingContext instances will get confused
     # and complain when they see the logcontext arbitrarily swapping
     # between the sentinel and `run` logcontexts.
     with PreserveLoggingContext():
         logger.info("Running")
         if cpu_affinity is not None:
             if not affinity:
                 quit_with_error(
                     "Missing package 'affinity' required for cpu_affinity\n"
                     "option\n\n"
                     "Install by running:\n\n"
                     "   pip install affinity\n\n"
                 )
             logger.info("Setting CPU affinity to %s" % cpu_affinity)
             affinity.set_process_affinity_mask(0, cpu_affinity)
         change_resource_limit(soft_file_limit)
         if gc_thresholds:
             gc.set_threshold(*gc_thresholds)
         reactor.run()
예제 #12
0
파일: pusher.py 프로젝트: 0-T-0/synapse
def setup(config_options):
    try:
        config = PusherSlaveConfig.load_config(
            "Synapse pusher", config_options
        )
    except ConfigError as e:
        sys.stderr.write("\n" + e.message + "\n")
        sys.exit(1)

    if not config:
        sys.exit(0)

    config.setup_logging()

    database_engine = create_engine(config.database_config)

    ps = PusherServer(
        config.server_name,
        db_config=config.database_config,
        config=config,
        version_string=get_version_string("Synapse", synapse),
        database_engine=database_engine,
    )

    ps.setup()
    ps.start_listening()

    change_resource_limit(ps.config.soft_file_limit)
    if ps.config.gc_thresholds:
        gc.set_threshold(*ps.config.gc_thresholds)

    def start():
        ps.replicate()
        ps.get_pusherpool().start()
        ps.get_datastore().start_profiling()

    reactor.callWhenRunning(start)

    return ps
예제 #13
0
def setup(config_options):
    try:
        config = SynchrotronConfig.load_config(
            "Synapse synchrotron", config_options
        )
    except ConfigError as e:
        sys.stderr.write("\n" + e.message + "\n")
        sys.exit(1)

    if not config:
        sys.exit(0)

    config.setup_logging()

    database_engine = create_engine(config.database_config)

    ss = SynchrotronServer(
        config.server_name,
        db_config=config.database_config,
        config=config,
        version_string=get_version_string("Synapse", synapse),
        database_engine=database_engine,
        application_service_handler=SynchrotronApplicationService(),
    )

    ss.setup()
    ss.start_listening()

    change_resource_limit(ss.config.soft_file_limit)
    if ss.config.gc_thresholds:
        ss.set_threshold(*ss.config.gc_thresholds)

    def start():
        ss.get_datastore().start_profiling()
        ss.replicate()

    reactor.callWhenRunning(start)

    return ss
예제 #14
0
def setup(config_options):
    try:
        config = PusherSlaveConfig.load_config("Synapse pusher",
                                               config_options)
    except ConfigError as e:
        sys.stderr.write("\n" + e.message + "\n")
        sys.exit(1)

    if not config:
        sys.exit(0)

    config.setup_logging()

    database_engine = create_engine(config.database_config)

    ps = PusherServer(
        config.server_name,
        db_config=config.database_config,
        config=config,
        version_string=get_version_string("Synapse", synapse),
        database_engine=database_engine,
    )

    ps.setup()
    ps.start_listening()

    change_resource_limit(ps.config.soft_file_limit)
    if ps.config.gc_thresholds:
        gc.set_threshold(*ps.config.gc_thresholds)

    def start():
        ps.replicate()
        ps.get_pusherpool().start()
        ps.get_datastore().start_profiling()

    reactor.callWhenRunning(start)

    return ps
예제 #15
0
 def startService(self):
     hs = setup(self.config)
     change_resource_limit(hs.config.soft_file_limit)
     if hs.config.gc_thresholds:
         gc.set_threshold(*hs.config.gc_thresholds)
예제 #16
0
 def run():
     with LoggingContext("run"):
         change_resource_limit(ps.config.soft_file_limit)
         if ps.config.gc_thresholds:
             gc.set_threshold(*ps.config.gc_thresholds)
         reactor.run()
예제 #17
0
 def startService(self):
     hs = setup(self.config)
     change_resource_limit(hs.config.soft_file_limit)
     if hs.config.gc_thresholds:
         gc.set_threshold(*hs.config.gc_thresholds)
예제 #18
0
파일: pusher.py 프로젝트: 0-T-0/synapse
 def run():
     with LoggingContext("run"):
         change_resource_limit(ps.config.soft_file_limit)
         if ps.config.gc_thresholds:
             gc.set_threshold(*ps.config.gc_thresholds)
         reactor.run()