def check_index_and_wipe_out(logger): """ Check index by running the indexer. If the index does not match currently running version and the CHECK_INDEX environment variable is non empty, wipe out the directories under data root. """ check_index = os.environ.get('CHECK_INDEX') if check_index and os.path.exists(OPENGROK_CONFIG_FILE): logger.info('Checking if index matches current version') indexer_options = ['-R', OPENGROK_CONFIG_FILE, '--checkIndex'] indexer = Indexer(indexer_options, logger=logger, jar=OPENGROK_JAR, doprint=True) indexer.execute() if indexer.getretcode() == 1: logger.info('Wiping out data root') root = OPENGROK_DATA_ROOT for entry in os.listdir(root): path = os.path.join(root, entry) if os.path.isdir(path): try: logger.info("Removing '{}'".format(path)) shutil.rmtree(path) except Exception as e: logger.error("cannot delete '{}': {}".format(path, e))
def indexer_no_projects(logger, uri, config_path, extra_indexer_options): """ Project less indexer """ wait_for_tomcat(logger, uri) while True: indexer_options = [ '-s', OPENGROK_SRC_ROOT, '-d', OPENGROK_DATA_ROOT, '-c', '/usr/local/bin/ctags', '--remote', 'on', '-H', '-W', config_path, '-U', uri ] if extra_indexer_options: logger.debug("Adding extra indexer options: {}".format( extra_indexer_options)) indexer_options.extend(extra_indexer_options.split()) indexer = Indexer(indexer_options, logger=logger, jar=OPENGROK_JAR, doprint=True) indexer.execute() logger.info("Waiting for reindex to be triggered") sleep_event.wait()
def indexer_no_projects(logger, uri, config_path, sync_period, extra_indexer_options): """ Project less indexer """ wait_for_tomcat(logger, uri) while True: indexer_options = ['-s', OPENGROK_SRC_ROOT, '-d', OPENGROK_DATA_ROOT, '-c', '/usr/local/bin/ctags', '--remote', 'on', '-H', '-W', config_path, '-U', uri] if extra_indexer_options: logger.debug("Adding extra indexer options: {}". format(extra_indexer_options)) indexer_options.extend(extra_indexer_options.split()) indexer = Indexer(indexer_options, logger=logger, jar=OPENGROK_JAR, doprint=True) indexer.execute() sleep_seconds = sync_period * 60 logger.info("Sleeping for {} seconds".format(sleep_seconds)) time.sleep(sleep_seconds)
def create_bare_config(logger, use_projects, extra_indexer_options=None): """ Create bare configuration file with a few basic settings. """ logger.info( 'Creating bare configuration in {}'.format(OPENGROK_CONFIG_FILE)) indexer_options = [ '-s', OPENGROK_SRC_ROOT, '-d', OPENGROK_DATA_ROOT, '-c', '/usr/local/bin/ctags', '--remote', 'on', '-H', '-S', '-W', OPENGROK_CONFIG_FILE, '--noIndex' ] if extra_indexer_options: if type(extra_indexer_options) is not list: raise Exception("extra_indexer_options has to be a list") indexer_options.extend(extra_indexer_options) if use_projects: indexer_options.append('-P') indexer = Indexer(indexer_options, jar=OPENGROK_JAR, logger=logger, doprint=True) indexer.execute() ret = indexer.getretcode() if ret != SUCCESS_EXITVAL: logger.error('Command returned {}'.format(ret)) logger.error(indexer.geterroutput()) raise Exception("Failed to create bare configuration")
def create_bare_config(logger): """ Create bare configuration file with a few basic settings. """ logger.info( 'Creating bare configuration in {}'.format(OPENGROK_CONFIG_FILE)) indexer = Indexer([ '-s', OPENGROK_SRC_ROOT, '-d', OPENGROK_DATA_ROOT, '-c', '/usr/local/bin/ctags', '--remote', 'on', '-P', '-H', '-W', OPENGROK_CONFIG_FILE, '--noIndex' ], jar=os.path.join(OPENGROK_LIB_DIR, 'opengrok.jar'), logger=logger, doprint=True) indexer.execute() ret = indexer.getretcode() if ret != SUCCESS_EXITVAL: logger.error('Command returned {}'.format(ret)) logger.error(indexer.geterroutput()) raise Exception("Failed to create bare configuration")