Exemplo n.º 1
0
 def clicked_force_shutdown(self):
     process_checker = ProcessChecker()
     if process_checker.already_running:
         core_pid = process_checker.get_pid_from_lock_file()
         os.kill(int(core_pid), 9)
     # Stop the Qt application
     QApplication.quit()
Exemplo n.º 2
0
 def test_dead_pid_in_lock_file(self):
     """Testing whether the process checker returns false when there is a dead pid in the lock file."""
     dead_pid = 134824733
     self.create_lock_file_with_pid(dead_pid)
     process_checker = ProcessChecker(state_directory=self.state_dir)
     self.assertFalse(process_checker.is_pid_running(dead_pid))
     self.assertFalse(process_checker.already_running)
Exemplo n.º 3
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()
Exemplo n.º 4
0
 def test_create_lock_file(self):
     """
     Testing if lock file is created
     """
     process_checker = ProcessChecker(state_directory=self.state_dir)
     process_checker.create_lock_file()
     self.assertTrue(os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
Exemplo n.º 5
0
 def clicked_force_shutdown(self):
     process_checker = ProcessChecker()
     if process_checker.already_running:
         core_pid = process_checker.get_pid_from_lock_file()
         os.kill(int(core_pid), 9)
     # Stop the Qt application
     QApplication.quit()
Exemplo n.º 6
0
def get_existing_tribler_pids():
    """ Get PID of all existing instances excluding the current one """
    pids = []
    if sys.platform == 'linux2':
        for proc in subprocess.check_output(['ps', '-ef']).splitlines():
            if 'python' in proc and 'run_tribler.py' in proc:
                pids += [int(proc.split()[1])]
    elif sys.platform == 'win32':
        pids = [int(item.split()[1]) for item in os.popen('tasklist').read().splitlines()[4:] if
                'tribler.exe' in item.split()]
    elif sys.platform == 'darwin':
        tribler_executable_partial_path = "Tribler.app/Contents/MacOS/tribler".lower()
        for proc in subprocess.check_output(['ps', '-ef']).splitlines():
            if tribler_executable_partial_path in proc.lower() or ('python' in proc and 'run_tribler.py' in proc):
                pids += [int(proc.split()[1])]

    # Remove the current instance PID from this list
    current_pid = os.getpid()
    # In Mac, there are two processes spawned somehow with consecutive pids, if so remove it from the list
    current_pid_list = [current_pid, current_pid - 1, current_pid + 1]
    for new_pid in current_pid_list:
        if new_pid in pids:
            pids.remove(new_pid)

    # Get core process PID from the lock file (if any) and add it to the PID list
    process_checker = ProcessChecker()
    if process_checker.already_running:
        core_pid = process_checker.get_pid_from_lock_file()
        if core_pid not in pids:
            pids.append(int(core_pid))

    return pids
Exemplo n.º 7
0
 def test_create_lock_file(self):
     """
     Testing if lock file is created
     """
     process_checker = ProcessChecker(state_directory=self.state_dir)
     process_checker.create_lock_file()
     self.assertTrue(os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
Exemplo n.º 8
0
 def test_dead_pid_in_lock_file(self):
     """Testing whether the process checker returns false when there is a dead pid in the lock file."""
     dead_pid = 134824733
     self.create_lock_file_with_pid(dead_pid)
     process_checker = ProcessChecker(state_directory=self.state_dir)
     self.assertFalse(process_checker.is_pid_running(dead_pid))
     self.assertFalse(process_checker.already_running)
Exemplo n.º 9
0
 def test_remove_lock_file(self):
     """
     Testing if lock file is removed on calling remove_lock_file()
     """
     process_checker = ProcessChecker(state_directory=self.state_dir)
     process_checker.create_lock_file()
     process_checker.remove_lock_file()
     self.assertFalse(os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
Exemplo n.º 10
0
    def test_other_instance_running(self):
        """Testing whether the process checker returns true when another process is running."""
        self.process = Process(target=process_dummy_function)
        self.process.start()

        self.create_lock_file_with_pid(self.process.pid)
        process_checker = ProcessChecker(state_directory=self.state_dir)
        self.assertTrue(process_checker.is_pid_running(self.process.pid))
        self.assertTrue(process_checker.already_running)
Exemplo n.º 11
0
    def test_other_instance_running(self):
        """Testing whether the process checker returns true when another process is running."""
        self.process = Process(target=process_dummy_function, args=(self.stop_flag,))
        self.process.start()

        self.create_lock_file_with_pid(self.process.pid)
        process_checker = ProcessChecker(state_directory=self.state_dir)
        self.assertTrue(process_checker.is_pid_running(self.process.pid))
        self.assertTrue(process_checker.already_running)
Exemplo n.º 12
0
    def test_invalid_pid_in_lock_file(self):
        """
        Testing pid should be -1 if the lock file is invalid
        """
        with open(os.path.join(self.state_dir, LOCK_FILE_NAME), 'wb') as lock_file:
            lock_file.write("Hello world")

        process_checker = ProcessChecker(state_directory=self.state_dir)
        self.assertEqual(process_checker.get_pid_from_lock_file(), -1)
Exemplo n.º 13
0
    def test_invalid_pid_in_lock_file(self):
        """
        Testing pid should be -1 if the lock file is invalid
        """
        with open(os.path.join(self.state_dir, LOCK_FILE_NAME), 'wb') as lock_file:
            lock_file.write("Hello world")

        process_checker = ProcessChecker(state_directory=self.state_dir)
        self.assertEqual(process_checker.get_pid_from_lock_file(), -1)
Exemplo n.º 14
0
    def test_invalid_pid_in_lock_file(self):
        """
        Test whether a new lock file is created when an invalid pid is written inside the current lock file
        """
        with open(os.path.join(self.state_dir, LOCK_FILE_NAME),
                  'wb') as lock_file:
            lock_file.write("Hello world")

        process_checker = ProcessChecker()
        self.assertGreater(int(process_checker.get_pid_from_lock_file()), 0)
Exemplo n.º 15
0
def run(params=[""],
        autoload_discovery=True,
        use_torrent_search=True,
        use_channel_search=True):

    from .hacks import patch_crypto_be_discovery
    patch_crypto_be_discovery()

    if len(sys.argv) > 1:
        if sys.platform.startswith("win"):
            from .hacks import get_unicode_sys_argv
            params = get_unicode_sys_argv()[1:]
        else:
            params = sys.argv[1:]
    try:
        # Create single instance semaphore
        process_checker = ProcessChecker()

        installdir = determine_install_dir()

        if not ALLOW_MULTIPLE and process_checker.already_running:
            logger.info("Client shutting down. Detected another instance.")
        else:
            # Launch first abc single instance
            app = wx.GetApp()
            if not app:
                app = TriblerApp(redirect=False)

            abc = ABCApp(params,
                         installdir,
                         autoload_discovery=autoload_discovery,
                         use_torrent_search=use_torrent_search,
                         use_channel_search=use_channel_search)
            app.set_abcapp(abc)
            if abc.frame:
                app.SetTopWindow(abc.frame)
                abc.frame.set_wxapp(app)
                app.MainLoop()

            # since ABCApp is not a wx.App anymore, we need to call OnExit explicitly.
            abc.OnExit()

            # Niels: No code should be present here, only executed after gui closes

        process_checker.remove_lock_file()

        logger.info(
            "Client shutting down. Sleeping for a few seconds to allow other threads to finish"
        )
        sleep(5)

    except:
        print_exc()
Exemplo n.º 16
0
    def start_tribler(self, options):
        """
        Main method to startup Tribler.
        """
        def on_tribler_shutdown(_):
            msg("Tribler shut down")
            reactor.stop()
            self.process_checker.remove_lock_file()

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                self.session.shutdown().addCallback(on_tribler_shutdown)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        config = TriblerConfig()
        config.set_torrent_checking_enabled(False)
        config.set_megacache_enabled(True)
        config.set_dispersy_enabled(False)
        config.set_mainline_dht_enabled(True)
        config.set_torrent_collecting_enabled(False)
        config.set_libtorrent_enabled(False)
        config.set_http_api_enabled(True)
        config.set_video_server_enabled(False)
        config.set_torrent_search_enabled(False)
        config.set_channel_search_enabled(False)
        config.set_credit_mining_enabled(False)
        config.set_dummy_wallets_enabled(True)
        config.set_popularity_community_enabled(False)

        # Check if we are already running a Tribler instance
        self.process_checker = ProcessChecker()
        if self.process_checker.already_running:
            self.shutdown_process(
                "Another Tribler instance is already using statedir %s" %
                config.get_state_dir())
            return

        msg("Starting Tribler")

        if options["statedir"]:
            config.set_state_dir(options["statedir"])

        if options["restapi"] > 0:
            config.set_http_api_enabled(True)
            config.set_http_api_port(options["restapi"])

        if options["ipv8"] != -1 and options["ipv8"] > 0:
            config.set_dispersy_port(options["ipv8"])

        if "testnet" in options and options["testnet"]:
            config.set_testnet(True)

        self.session = Session(config)
        self.session.start().addErrback(
            lambda failure: self.shutdown_process(failure.getErrorMessage()))
        msg("Tribler started")
Exemplo n.º 17
0
 def test_own_pid_in_lock_file(self):
     """
     Testing whether the process checker returns True when it finds its own pid in the lock file
     """
     self.create_lock_file_with_pid(os.getpid())
     process_checker = ProcessChecker(state_directory=self.state_dir)
     self.assertTrue(process_checker.already_running)
Exemplo n.º 18
0
 def test_no_lock_file(self):
     """
     Testing whether the process checker returns false when there is no lock file
     """
     process_checker = ProcessChecker()
     self.assertTrue(
         os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
     self.assertFalse(process_checker.already_running)
Exemplo n.º 19
0
 def test_no_lock_file(self):
     """
     Testing whether the process checker returns false when there is no lock file
     """
     process_checker = ProcessChecker(state_directory=self.state_dir)
     # Process checker does not create a lock file itself now, Core manager will call to create it.
     self.assertFalse(os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
     self.assertFalse(process_checker.already_running)
Exemplo n.º 20
0
    def start_tribler():
        config = SessionStartupConfig().load()
        config.set_http_api_port(API_PORT)
        config.set_http_api_enabled(True)

        # Check if we are already running a Tribler instance
        process_checker = ProcessChecker()
        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()
Exemplo n.º 21
0
class ShutdownEndpoint(resource.Resource):
    """
    With this endpoint you can shutdown Tribler.
    """

    def __init__(self, session):
        resource.Resource.__init__(self)
        self._logger = logging.getLogger(self.__class__.__name__)
        self.session = session
        self.process_checker = ProcessChecker()

    def render_PUT(self, request):
        """
        .. http:put:: /shutdown

        A PUT request to this endpoint will shutdown Tribler.

            **Example request**:

            .. sourcecode:: none

                curl -X PUT http://localhost:8085/shutdown

            **Example response**:

            .. sourcecode:: javascript

                {
                    "shutdown": True
                }
        """
        def shutdown_process(_, code=1):
            reactor.addSystemEventTrigger('after', 'shutdown', os._exit, code)
            reactor.stop()
            self.process_checker.remove_lock_file()

        def log_and_shutdown(failure):
            self._logger.error(failure.value)
            shutdown_process(failure, 0)

        task.deferLater(reactor, 0, self.session.shutdown) \
            .addCallback(shutdown_process) \
            .addErrback(log_and_shutdown)

        return json.dumps({"shutdown": True})
Exemplo n.º 22
0
class ShutdownEndpoint(resource.Resource):
    """
    With this endpoint you can shutdown Tribler.
    """
    def __init__(self, session):
        resource.Resource.__init__(self)
        self._logger = logging.getLogger(self.__class__.__name__)
        self.session = session
        self.process_checker = ProcessChecker()

    def render_PUT(self, request):
        """
        .. http:put:: /shutdown

        A PUT request to this endpoint will shutdown Tribler.

            **Example request**:

            .. sourcecode:: none

                curl -X PUT http://localhost:8085/shutdown

            **Example response**:

            .. sourcecode:: javascript

                {
                    "shutdown": True
                }
        """
        def shutdown_process(_, code=1):
            reactor.addSystemEventTrigger('after', 'shutdown', os._exit, code)
            reactor.stop()
            self.process_checker.remove_lock_file()

        def log_and_shutdown(failure):
            self._logger.error(failure.value)
            shutdown_process(failure, 0)

        task.deferLater(reactor, 0, self.session.shutdown) \
            .addCallback(shutdown_process) \
            .addErrback(log_and_shutdown)

        return json.dumps({"shutdown": True})
Exemplo n.º 23
0
    def start_tribler(self, options):
        """
        Main method to startup Tribler.
        """
        def on_tribler_shutdown(_):
            msg("Tribler shut down")
            reactor.stop()
            self.process_checker.remove_lock_file()

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                self.session.shutdown().addCallback(on_tribler_shutdown)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        config = TriblerConfig()

        # Check if we are already running a Tribler instance
        self.process_checker = ProcessChecker()
        if self.process_checker.already_running:
            self.shutdown_process("Another Tribler instance is already using statedir %s" % config.get_state_dir())
            return

        msg("Starting Tribler")

        if options["statedir"]:
            config.set_state_dir(options["statedir"])

        if options["restapi"] > 0:
            config.set_http_api_enabled(True)
            config.set_http_api_port(options["restapi"])

        if options["dispersy"] > 0:
            config.set_dispersy_port(options["dispersy"])

        if options["libtorrent"] != -1 and options["libtorrent"] > 0:
            config.set_libtorrent_port(options["libtorrent"])

        self.session = Session(config)
        self.session.start().addErrback(lambda failure: self.shutdown_process(failure.getErrorMessage()))
        msg("Tribler started")

        if "auto-join-channel" in options and options["auto-join-channel"]:
            msg("Enabling auto-joining of channels")
            for community in self.session.get_dispersy_instance().get_communities():
                if isinstance(community, AllChannelCommunity):
                    community.auto_join_channel = True

        if "log-incoming-searches" in options and options["log-incoming-searches"]:
            msg("Logging incoming remote searches")
            for community in self.session.get_dispersy_instance().get_communities():
                if isinstance(community, SearchCommunity):
                    community.log_incoming_searches = self.log_incoming_remote_search
Exemplo n.º 24
0
    def start_tribler():
        config = TriblerConfig()
        patch_wallet_methods()
        patch_iom_methods()

        config.set_http_api_port(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()
Exemplo n.º 25
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()
Exemplo n.º 26
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()
Exemplo n.º 27
0
    def start_tribler(self, options):
        """
        Main method to startup Tribler.
        """
        def on_tribler_shutdown(_):
            msg("Tribler shut down")
            reactor.stop()
            self.process_checker.remove_lock_file()

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                self.session.shutdown().addCallback(on_tribler_shutdown)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        config = TriblerConfig()

        # Check if we are already running a Tribler instance
        self.process_checker = ProcessChecker()
        if self.process_checker.already_running:
            self.shutdown_process("Another Tribler instance is already using statedir %s" % config.get_state_dir())
            return

        msg("Starting Tribler")

        if options["statedir"]:
            config.set_state_dir(options["statedir"])

        if options["restapi"] > 0:
            config.set_http_api_enabled(True)
            config.set_http_api_port(options["restapi"])

        if options["ipv8"] > 0:
            config.set_ipv8_port(options["ipv8"])
        elif options["ipv8"] == 0:
            config.set_ipv8_enabled(False)

        if options["libtorrent"] != -1 and options["libtorrent"] > 0:
            config.set_libtorrent_port(options["libtorrent"])

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

        if "testnet" in options and options["testnet"]:
            config.set_testnet(True)

        self.session = Session(config)
        self.session.start().addErrback(lambda failure: self.shutdown_process(failure.getErrorMessage()))
        msg("Tribler started")
Exemplo n.º 28
0
 def test_remove_lock_file(self):
     """
     Testing if lock file is removed on calling remove_lock_file()
     """
     process_checker = ProcessChecker(state_directory=self.state_dir)
     process_checker.create_lock_file()
     process_checker.remove_lock_file()
     self.assertFalse(os.path.exists(os.path.join(self.state_dir, LOCK_FILE_NAME)))
Exemplo n.º 29
0
    def start_tribler():
        config = TriblerConfig()
        config.set_http_api_port(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

        session = Session(config)

        signal.signal(signal.SIGTERM,
                      lambda signum, stack: shutdown(session, signum, stack))
        session.start()
Exemplo n.º 30
0
 def __init__(self, session):
     resource.Resource.__init__(self)
     self._logger = logging.getLogger(self.__class__.__name__)
     self.session = session
     self.process_checker = ProcessChecker()
Exemplo n.º 31
0
 def __init__(self, session):
     resource.Resource.__init__(self)
     self._logger = logging.getLogger(self.__class__.__name__)
     self.session = session
     self.process_checker = ProcessChecker()
Exemplo n.º 32
0
    def start_tribler(self, options):
        """
        Main method to startup Tribler.
        """

        def on_tribler_shutdown(_):
            msg("Tribler shut down")
            reactor.stop()
            self.process_checker.remove_lock_file()

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                self.session.shutdown().addCallback(on_tribler_shutdown)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        config = TriblerConfig()

        self.process_checker = ProcessChecker()
        if self.process_checker.already_running:
            self.shutdown_process("Another Tribler instance is already using statedir %s" % config.get_state_dir())
            return

        # Enable exitnode if set in options
        if "exitnode" in options and options["exitnode"]:
            msg("Enabling exitnode")
            config.set_tunnel_community_enabled(True)
            config.set_tunnel_community_exitnode_enabled(True)
        else:
            config.set_tunnel_community_exitnode_enabled(False)

        # Enable bitcoin testnet
        if "testnet" in options and options["testnet"]:
            msg("Enabling bitcoin testnet")
            config.set_testnet(True)

        # Enable dummy wallets
        if "dummy" in options and options["dummy"]:
            msg("Enabling dummy wallets")
            config.set_dummy_wallets_enabled(True)

        # Enable record transactions
        msg("Enabling record transactions")
        config.set_record_transactions(True)

        # Minimize functionality enabled for plebnet
        # For now, config taken from market_plugin in devos tribler repo
        config.set_http_api_enabled(True)
        config.set_video_server_enabled(False)
        config.set_torrent_search_enabled(False)
        config.set_channel_search_enabled(False)
        config.set_mainline_dht_enabled(True)
        config.set_dht_enabled(True)
        config.set_chant_enabled(False)
        config.set_bitcoinlib_enabled(True)

        msg("Starting Tribler")

        if options["statedir"]:
            config.set_state_dir(options["statedir"])

        if options["restapi"] > 0:
            config.set_http_api_enabled(True)
            config.set_http_api_port(options["restapi"])

        if options["dispersy"] != -1 and options["dispersy"] > 0:
            config.set_dispersy_port(options["dispersy"])

        if options["libtorrent"] != -1 and options["libtorrent"] > 0:
            config.set_libtorrent_port(options["libtorrent"])

        self.session = Session(config)
        self.session.start().addErrback(lambda failure: self.shutdown_process(failure.getErrorMessage()))

        msg("Tribler started")
Exemplo n.º 33
0
    def start_tribler(self, options):
        """
        Main method to startup Tribler.
        """
        def on_tribler_shutdown(_):
            msg("Tribler shut down")
            reactor.stop()
            self.process_checker.remove_lock_file()

        def signal_handler(sig, _):
            msg("Received shut down signal %s" % sig)
            if not self._stopping:
                self._stopping = True
                self.session.shutdown().addCallback(on_tribler_shutdown)

        signal.signal(signal.SIGINT, signal_handler)
        signal.signal(signal.SIGTERM, signal_handler)

        config = TriblerConfig()
        config.set_torrent_checking_enabled(False)
        config.set_megacache_enabled(True)
        config.set_credit_mining_enabled(False)
        config.set_dispersy_enabled(False)
        config.set_mainline_dht_enabled(False)
        config.set_torrent_collecting_enabled(False)
        config.set_libtorrent_enabled(False)
        config.set_http_api_enabled(True)
        config.set_video_server_enabled(False)
        config.set_torrent_search_enabled(False)
        config.set_channel_search_enabled(False)
        config.set_market_community_enabled(False)
        config.set_trustchain_enabled(
            False)  # We load the TriblerChain community ourselves

        # Check if we are already running a Tribler instance
        self.process_checker = ProcessChecker()
        if self.process_checker.already_running:
            self.shutdown_process(
                "Another Tribler instance is already using statedir %s" %
                config.get_state_dir())
            return

        msg("Starting TriblerChain crawler")

        if options["statedir"]:
            config.set_state_dir(options["statedir"])

        if options["restapi"] > 0:
            config.set_http_api_enabled(True)
            config.set_http_api_port(options["restapi"])

        if options["ipv8"] != -1 and options["ipv8"] > 0:
            config.set_dispersy_port(options["ipv8"])

        def on_tribler_started(_):
            # We load the TriblerChain community.
            triblerchain_peer = Peer(self.session.trustchain_keypair)
            self.triblerchain_community = TriblerChainCrawlerCommunity(
                triblerchain_peer,
                self.session.lm.ipv8.endpoint,
                self.session.lm.ipv8.network,
                tribler_session=self.session,
                working_directory=self.session.config.get_state_dir())
            self.session.lm.ipv8.overlays.append(self.triblerchain_community)
            self.session.lm.ipv8.strategies.append(
                (RandomWalk(self.triblerchain_community), -1))

        self.session = Session(config)
        self.session.start().addCallback(on_tribler_started).addErrback(
            lambda failure: self.shutdown_process(failure.getErrorMessage()))
        msg("TriblerChain crawler started")
Exemplo n.º 34
0
def get_existing_tribler_pid():
    """ Get PID of existing instance if present from the lock file (if any)"""
    process_checker = ProcessChecker()
    if process_checker.already_running:
        return process_checker.get_pid_from_lock_file()
    return -1
Exemplo n.º 35
0
def get_existing_tribler_pid():
    """ Get PID of existing instance if present from the lock file (if any)"""
    process_checker = ProcessChecker()
    if process_checker.already_running:
        return process_checker.get_pid_from_lock_file()
    return -1