Esempio n. 1
0
    def start_tribler():
        config = TriblerConfig()
        global trace_logger

        # Enable tracer if --trace-debug or --trace-exceptions flag is present in sys.argv
        trace_logger = check_and_enable_code_tracing('core')

        priority_order = config.get_cpu_priority_order()
        set_process_priority(pid=os.getpid(), priority_order=priority_order)

        config.set_http_api_port(int(api_port))
        config.set_http_api_enabled(True)

        # Check if we are already running a Tribler instance
        process_checker = ProcessChecker(config.get_state_dir())
        if process_checker.already_running:
            return
        else:
            process_checker.create_lock_file()

        session = Session(config)

        signal.signal(signal.SIGTERM,
                      lambda signum, stack: shutdown(session, signum, stack))
        session.start()
    def start(self):
        # Determine socks5 ports
        socks5_port = self.options['socks5']
        if "HELPER_INDEX" in os.environ and "HELPER_BASE" in os.environ:
            base_port = int(os.environ["HELPER_BASE"])
            socks5_port = base_port + int(os.environ["HELPER_INDEX"]) * 5

        if socks5_port is not None:
            socks_listen_ports = range(socks5_port, socks5_port + 5)
        else:
            socks_listen_ports = [
                random.randint(1000, 65535) for _ in range(5)
            ]

        config = TriblerConfig()
        config.set_state_dir(
            os.path.join(config.get_state_dir(), "tunnel-%d") %
            socks_listen_ports[0])
        config.set_tunnel_community_socks5_listen_ports(socks_listen_ports)
        config.set_torrent_checking_enabled(False)
        config.set_megacache_enabled(False)
        config.set_dispersy_enabled(False)
        config.set_ipv8_enabled(True)
        config.set_mainline_dht_enabled(True)
        config.set_torrent_collecting_enabled(False)
        config.set_libtorrent_enabled(False)
        config.set_video_server_enabled(False)
        config.set_dispersy_port(self.ipv8_port)
        config.set_ipv8_address(self.ipv8_address)
        config.set_torrent_search_enabled(False)
        config.set_channel_search_enabled(False)
        config.set_trustchain_enabled(True)
        config.set_credit_mining_enabled(False)
        config.set_market_community_enabled(False)
        config.set_mainline_dht_enabled(False)
        config.set_dht_enabled(True)
        config.set_tunnel_community_exitnode_enabled(bool(
            self.options["exit"]))
        config.set_popularity_community_enabled(False)
        config.set_testnet(bool(self.options["testnet"]))

        if self.options["restapi"] is not None:
            config.set_http_api_enabled(True)
            config.set_http_api_port(self.options["restapi"])

        if self.options["ipv8_bootstrap_override"] is not None:
            config.set_ipv8_bootstrap_override(
                self.options["ipv8_bootstrap_override"])

        self.session = Session(config)
        logger.info("Using IPv8 port %d" %
                    self.session.config.get_dispersy_port())

        self.session.notifier.add_observer(self.circuit_removed, NTFY_TUNNEL,
                                           [NTFY_REMOVE])

        return self.session.start().addCallback(self.tribler_started)
Esempio n. 3
0
    def start(self):
        # Determine ipv8 port
        ipv8_port = -1
        if self.options["ipv8_port"] != -1:
            ipv8_port = self.options["ipv8_port"]
        elif "HELPER_INDEX" in os.environ and "HELPER_BASE" in os.environ:
            base_port = int(os.environ["HELPER_BASE"])
            ipv8_port = base_port + int(os.environ["HELPER_INDEX"]) * 5

        config = TriblerConfig()
        config.set_state_dir(os.path.join(config.get_state_dir(), "tunnel-%d") % ipv8_port)
        config.set_tunnel_community_socks5_listen_ports([])
        config.set_torrent_checking_enabled(False)
        config.set_megacache_enabled(False)
        config.set_dispersy_enabled(False)
        config.set_ipv8_enabled(True)
        config.set_torrent_collecting_enabled(False)
        config.set_libtorrent_enabled(False)
        config.set_video_server_enabled(False)
        config.set_dispersy_port(ipv8_port)
        config.set_ipv8_address(self.options["ipv8_address"])
        config.set_torrent_search_enabled(False)
        config.set_channel_search_enabled(False)
        config.set_trustchain_enabled(True)
        config.set_credit_mining_enabled(False)
        config.set_market_community_enabled(False)
        config.set_mainline_dht_enabled(False)
        config.set_dht_enabled(True)
        config.set_tunnel_community_exitnode_enabled(bool(self.options["exit"]))
        config.set_popularity_community_enabled(False)
        config.set_testnet(bool(self.options["testnet"]))

        if not self.options['no-rest-api']:
            config.set_http_api_enabled(True)
            api_port = self.options["restapi"]
            if "HELPER_INDEX" in os.environ and "HELPER_BASE" in os.environ:
                api_port = int(os.environ["HELPER_BASE"]) + 10000 + int(os.environ["HELPER_INDEX"])
            config.set_http_api_port(api_port)

        if self.options["ipv8_bootstrap_override"] is not None:
            config.set_ipv8_bootstrap_override(self.options["ipv8_bootstrap_override"])

        self.session = Session(config)
        logger.info("Using IPv8 port %d" % self.session.config.get_dispersy_port())

        self.session.notifier.add_observer(self.circuit_removed, NTFY_TUNNEL, [NTFY_REMOVE])

        return self.session.start().addCallback(self.tribler_started)
Esempio n. 4
0
    def start_tribler():
        config = TriblerConfig()

        priority_order = config.get_cpu_priority_order()
        set_process_priority(pid=os.getpid(), priority_order=priority_order)

        config.set_http_api_port(int(api_port))
        config.set_http_api_enabled(True)

        # Check if we are already running a Tribler instance
        process_checker = ProcessChecker(config.get_state_dir())
        if process_checker.already_running:
            return
        else:
            process_checker.create_lock_file()

        session = Session(config)

        signal.signal(signal.SIGTERM, lambda signum, stack: shutdown(session, signum, stack))
        session.start()
Esempio n. 5
0
    def start_tribler():
        config = TriblerConfig()

        priority_order = config.get_cpu_priority_order()
        set_process_priority(pid=os.getpid(), priority_order=priority_order)

        config.set_http_api_port(int(api_port))
        config.set_http_api_enabled(True)

        # Check if we are already running a Tribler instance
        process_checker = ProcessChecker(config.get_state_dir())
        if process_checker.already_running:
            return
        else:
            process_checker.create_lock_file()

        session = Session(config)

        signal.signal(signal.SIGTERM,
                      lambda signum, stack: shutdown(session, signum, stack))
        session.start()
Esempio n. 6
0
    async def start_tribler():
        # Check if we are already running a Tribler instance
        process_checker = ProcessChecker(root_state_dir)
        if process_checker.already_running:
            return
        process_checker.create_lock_file()

        # Before any upgrade, prepare a separate state directory for the update version so it does not
        # affect the older version state directory. This allows for safe rollback.
        fork_state_directory_if_necessary(root_state_dir, version_id)

        state_dir = get_versioned_state_directory(root_state_dir)

        config = TriblerConfig(state_dir,
                               config_file=state_dir / CONFIG_FILENAME)
        config.set_http_api_port(int(api_port))
        # If the API key is set to an empty string, it will remain disabled
        if config.get_http_api_key() not in ('', api_key):
            config.set_http_api_key(api_key)
            config.write(
            )  # Immediately write the API key so other applications can use it
        config.set_http_api_enabled(True)

        priority_order = config.get_cpu_priority_order()
        set_process_priority(pid=os.getpid(), priority_order=priority_order)

        global trace_logger
        # Enable tracer if --trace-debug or --trace-exceptions flag is present in sys.argv
        trace_logger = check_and_enable_code_tracing('core',
                                                     config.get_log_dir())

        session = Session(config)

        signal.signal(signal.SIGTERM,
                      lambda signum, stack: shutdown(session, signum, stack))
        await session.start()