【OpenGrok代码搜索引擎】三、OpenGrok常用命令

【OpenGrok代码搜索引擎】三、OpenGrok常用命令写在前面为了防止一些无法预料的情况发生,建议在完成代码项目索引创建后对索引生成器(indexer)生成的配置文件configuration.xml进行备份。一、免配置方法可以使用一个OpenGrokDocker容器,该容器包含了OpenGrok配置环境,但需要注意的是,该容器不适合大型的代码项目。详细参考链接如下:opengrok/dockeratmaster·oracle/opengrok·GitHubDockerHub二、常用命令2…

大家好,又见面了,我是你们的朋友全栈君。

写在前面

        为了防止一些无法预料的情况发生,建议在完成代码项目索引创建后对索引生成器(indexer)生成的配置文件configuration.xml进行备份。

一、免配置方法

可以使用一个OpenGrok Docker容器,该容器包含了OpenGrok配置环境,但需要注意的是,该容器不适合大型的代码项目。

详细参考链接如下:

opengrok/docker at master · oracle/opengrok · GitHub

Docker Hub

二、常用命令

2.1 查看帮助

java -jar /opengrok/dist/lib/opengrok.jar -h

opengrok-indexer -a /opengrok/dist/lib/opengrok.jar — -h

执行结果如下:

Apr 03, 2022 10:21:08 AM org.opengrok.indexer.index.Indexer parseOptions
INFO: Indexer options: [-h]

Usage: java -jar opengrok.jar [options] [subDir1 [...]]

  //帮助参数
  -h, -?, --help [mode]
        With no mode specified, display this usage summary. Or specify a mode:
          config - display configuration.xml examples.
           ctags - display ctags command-line.
            guru - display AnalyzerGuru details.
           repos - display enabled repositories.
  //设置同步API超时
  --apiTimeout number
        Set timeout for asynchronous API requests.

  //设置连接API超时
  --connectTimeout number
        Set connect timeout. Used for API requests.

  //设置分析器支持的格式,如拓展名,前缀等。
  -A, --analyzer (.ext|prefix.):(-|analyzer)
        Associates files with the specified prefix or extension (case-
        insensitive) to be analyzed with the given analyzer, where 'analyzer'
        may be specified using a class name (case-sensitive e.g. RubyAnalyzer)
        or analyzer language name (case-sensitive e.g. C). Option may be
        repeated.
          Ex: -A .foo:CAnalyzer
              will use the C analyzer for all files ending with .FOO
          Ex: -A bar.:Perl
              will use the Perl analyzer for all files starting with
              "BAR" (no full-stop)
          Ex: -A .c:-
              will disable specialized analyzers for all files ending with .c

  //指定ctags路径
  -c, --ctags /path/to/ctags
        Path to Universal Ctags. Default is ctags in environment PATH.

  //指定canonicalRoot路径
  --canonicalRoot /path/
        Allow symlinks to canonical targets starting with the specified root
        without otherwise needing to specify -N,--symlink for such symlinks. A
        canonical root must end with a file separator. For security, a canonical
        root cannot be the root directory. Option may be repeated.

  //检查索引
  --checkIndex
        Check index, exit with 0 on success,
        with 1 on failure.

  //指定OpenGrok数据生成的路径
  -d, --dataRoot /path/to/data/root
        The directory where OpenGrok stores the generated data.

  //指定代码仓扫描目录深度,默认为2
  --depth number
        Scanning depth for repositories in directory structure relative to
        source root. Default is 2.

  //不使能
  --disableRepository type_name
        Disables operation of an OpenGrok-supported repository. See also
        -h,--help repos. Option may be repeated.
          Ex: --disableRepository git
              will disable the GitRepository
          Ex: --disableRepository MercurialRepository

  //节省磁盘空间,OpenGrok不产生和保存超文本交叉引用文件等。
  -e, --economical
        To consume less disk space, OpenGrok will not generate and save
        hypertext cross-reference files but will generate on demand, which could
        be slightly slow.

  -G, --assignTags
        Assign commit tags to all entries in history for all repositories.

  //使能历史信息
  -H, --history
        Enable history.

  --historyThreads number
        The number of threads to use for history cache generation on repository level. By default                                                                                                         the number of threads will be set to the number of available CPUs.
        Assumes -H/--history.

  --historyFileThreads number
        The number of threads to use for history cache generation when dealing with individual fil                                                                                                        es.
        By default the number of threads will be set to the number of available CPUs.
        Assumes -H/--history.

  -I, --include pattern
        Only files matching this pattern will be examined. Pattern supports
        wildcards (example: -I '*.java' -I '*.c'). Option may be repeated.

  -i, --ignore pattern
        Ignore matching files (prefixed with 'f:' or no prefix) or directories
        (prefixed with 'd:'). Pattern supports wildcards (example: -i '*.so'
        -i d:'test*'). Option may be repeated.

  -l, --lock on|off|simple|native
        Set OpenGrok/Lucene locking mode of the Lucene database during index
        generation. "on" is an alias for "simple". Default is off.

  --leadingWildCards on|off
        Allow or disallow leading wildcards in a search. Default is on.

  -m, --memory number
        Amount of memory (MB) that may be used for buffering added documents and
        deletions before they are flushed to the directory (default 16.0).
        Please increase JVM heap accordingly too.

  --mandoc /path/to/mandoc
        Path to mandoc(1) binary.

  -N, --symlink /path/to/symlink
        Allow the symlink to be followed. Other symlinks targeting the same
        canonical target or canonical children will be allowed too. Option may
        be repeated. (By default only symlinks directly under the source root
        directory are allowed. See also --canonicalRoot)

  -n, --noIndex
        Do not generate indexes and other data (such as history cache and xref
        files), but process all other command line options.

  --nestingMaximum number
        Maximum depth of nested repositories. Default is 1.

  -O, --optimize on|off
        Turn on/off the optimization of the index database as part of the
        indexing step. Default is on.

  -o, --ctagOpts path
        File with extra command line options for ctags.

  -P, --projects
        Generate a project for each top-level directory in source root.

  -p, --defaultProject path/to/default/project
        Path (relative to the source root) to a project that should be selected
        by default in the web application (when no other project is set either
        in a cookie or in parameter). Option may be repeated to specify several
        projects. Use the special value __all__ to indicate all projects.

  --profiler
        Pause to await profiler or debugger.

  --progress
        Print per-project percentage progress information.

  -Q, --quickScan on|off
        Turn on/off quick context scan. By default, only the first 1024KB of a
        file is scanned, and a link ('[..all..]') is inserted when the file is
        bigger. Activating this may slow the server down. (Note: this setting
        only affects the web application.) Default is on.

  -q, --quiet
        Run as quietly as possible. Sets logging level to WARNING.

  -R /path/to/configuration
        Read configuration from the specified file.

  -r, --remote on|off|uionly|dirbased
        Specify support for remote SCM systems.
              on - allow retrieval for remote SCM systems.
             off - ignore SCM for remote systems.
          uionly - support remote SCM for user interface only.
        dirbased - allow retrieval during history index only for repositories
                   which allow getting history for directories.

  --renamedHistory on|off
        Enable or disable generating history for renamed files.
        If set to on, makes history indexing slower for repositories
        with lots of renamed files. Default is off.

  --repository [path/to/repository|@file_with_paths]
        Path (relative to the source root) to a repository for generating
        history (if -H,--history is on). By default all discovered repositories
        are history-eligible; using --repository limits to only those specified.
        File containing paths can be specified via @path syntax.
        Option may be repeated.

  -S, --search [path/to/repository|@file_with_paths]
        Search for source repositories under -s,--source, and add them. Path
        (relative to the source root) is optional.
        File containing paths can be specified via @path syntax.
        Option may be repeated.

  -s, --source /path/to/source/root
        The root directory of the source tree.

  --style path
        Path to the subdirectory in the web application containing the requested
        stylesheet. The factory-setting is: "default".

  -T, --threads number
        The number of threads to use for index generation, repository scan
        and repository invalidation.
        By default the number of threads will be set to the number of available
        CPUs. This influences the number of spawned ctags processes as well.

  -t, --tabSize number
        Default tab size to use (number of spaces per tab character).

  --token string|@file_with_string
        Authorization bearer API token to use when making API calls
        to the web application

  -U, --uri SCHEME://webappURI:port/contextPath
        Send the current configuration to the specified web application.

  --updateConfig
        Populate the web application with a bare configuration, and exit.

  --userPage URL
        Base URL of the user Information provider.
        Example: "https://www.example.org/viewProfile.jspa?username=".
        Use "none" to disable link.

  --userPageSuffix URL-suffix
        URL Suffix for the user Information provider. Default: "".

  -V, --version
        Print version, and quit.

  -v, --verbose
        Set logging level to INFO.

  -W, --writeConfig /path/to/configuration
        Write the current configuration to the specified file (so that the web
        application can use the same configuration).

  --webappCtags on|off
        Web application should run ctags when necessary. Default is off.

2.2 创建/更新索引

java \
    -Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -jar /opengrok/dist/lib/opengrok.jar \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -P -S -G \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

或使用OpenGrok管理工具包中的opengrok-indexer

opengrok-indexer \
    -J=-Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -a /opengrok/dist/lib/opengrok.jar — \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -P -S -G \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

2.3 创建单个项目的索引或新增一个项目的索引

java \
    -Djava.util.logging.config.file=/opengrok/etc/logging.properties \
    -jar /opengrok/dist/lib/opengrok.jar \
    -c /usr/local/bin/ctags \
    -s /opengrok/src -d /opengrok/data -H -S -G -p /opengrok/src/06_systemd \
    -W /opengrok/etc/configuration.xml -U http://localhost:8080/source

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/131415.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • IT速查手册[通俗易懂]

    IT速查手册[通俗易懂]发现一个很好的点评公司网站,很有创意。里面大部分的评论都来自公司内部的员工。  想找IT工作的,可以先到那里了解公司的待遇、环境、内部等问题。  公司点评网:

    2022年7月1日
    35
  • 矩阵特征值分解(EDV)与奇异值分解(SVD)在机器学习中的应用

    目录特征分解定义(来自百度百科词条:特征分解)特征分解(Eigendecomposition),又称谱分解(Spectraldecomposition)是将矩阵分解为由其特征值和特征向量表示的矩阵之积的方法。需要注意只有对可对角化矩阵才可以施以特征分解。(来自百度百科词条:矩阵特征值)什么是特征值,特征向量?设A是n阶方阵,如果数λ和n维非零列向量x使关系式Ax=λx成立,那么这样的数λ称为矩阵A特征值,非零向量x称为A的对应于特征值λ的特征向量。式Ax=λx也可写成(A-λE)X=0。这是

    2022年4月5日
    50
  • 事务日志初探(二)—简单恢复模式

    事务日志初探(二)—简单恢复模式

    2021年11月25日
    46
  • 第一次训练赛总结

    第一次训练赛总结

    2021年9月27日
    49
  • 数据权限设计(转载)

    数据权限设计(转载)一、前言几乎在任何一个系统中,都离不开权限的设计,权限设计=功能权限+数据权限,而功能权限,在业界常常是基于RBAC(Role-BasedAccessControl)的一套方案。而数据权限,则根据不同的业务场景,则权限却不尽相同,应该根据具体的场景巧妙设计;且必须在项目开始时进行设计,不像功能权限一样,在项目结束的时候在追加。注:更细还可以加入字段权限1.1权限…

    2022年7月16日
    14
  • GPS数据格式分析

    GPS数据格式分析GPS数据格式分析

    2022年6月23日
    27

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号