def start(self, eager: bool = False): """Start the crawler if not already running""" if not self.is_running: self.log.info('Starting Crawler...') if self._influx_client is None: self._influx_client = InfluxDBClient( host=self._db_host, port=self._db_port, database=self.INFLUX_DB_NAME) self._initialize_influx() if self._crawler_client is None: from monitor.db import CrawlerStorageClient self._crawler_client = CrawlerStorageClient() # TODO: Maybe? # from monitor.db import CrawlerInfluxClient # self.crawler_influx_client = CrawlerInfluxClient() # start tasks node_learner_deferred = self._node_details_task.start( interval=random.randint( int(self._refresh_rate * (1 - self.REFRESH_RATE_WINDOW)), self._refresh_rate), now=eager) time.sleep(random.randint(2, 10)) # random stagger start of task collection_deferred = self._stats_collection_task.start( interval=random.randint( self._refresh_rate, int(self._refresh_rate * (1 + self.REFRESH_RATE_WINDOW))), now=eager) # get known last event block self.__events_from_block = self._get_last_known_blocknumber() time.sleep(random.randint(2, 10)) # random stagger start of task events_deferred = self._events_collection_task.start( interval=self._refresh_rate, now=eager) # hookup error callbacks node_learner_deferred.addErrback(self._handle_errors) collection_deferred.addErrback(self._handle_errors) events_deferred.addErrback(self._handle_errors) # Start up self.start_learning_loop(now=False) self.make_flask_server() hx_deployer = HendrixDeploy(action="start", options={ "wsgi": self._flask, "http_port": self._crawler_http_port }) hx_deployer.run() # <--- Blocking Call to Reactor
def test_node_client_init_values(): temp_db_filepath = "/tmp/test.db" node_db_client = CrawlerStorageClient(temp_db_filepath) assert node_db_client._db_filepath == temp_db_filepath