【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

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

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

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • js常用的4种截取字符串方法_js常用的4种截取字符串方法

    js常用的4种截取字符串方法_js常用的4种截取字符串方法字符串内是否包含某个字符串——indexOfvaroldString=“tongyuwan”;varnewString=oldString.indexOf(‘tong’);if(newStrong)

  • vscode连接力扣题库

    vscode连接力扣题库vscode连接力扣题库下载力扣插件回到力扣,点击题库,打开开发者工具(f12),点击网络,再次点击题库,点击标头,下滑找到cookie,复制cookie的值回到vscode,点击力扣图标,点击登录图标(如图),选择cookie登录,将刚刚复制的cookie值粘贴在这里即可…

    2022年10月23日
  • vue子组件给父组件传值 接收不到数据_vue父向子组件传值

    vue子组件给父组件传值 接收不到数据_vue父向子组件传值Usage: 子组件内容:<template><div@click="iclick"></div></template>methods:{iclick(){letdata={a:’data’};this.$emit(‘ievent’,data,’l…

  • 高并发解决方案-代理服务器Nginx[通俗易懂]

    高并发解决方案-代理服务器Nginx[通俗易懂]文章目录Nginx1.Nginx概念2.Nginx的应用场景3.Linux环境下Nginx的安装与启动4.Nginx静态网站部署5.Nginx配置虚拟主机5.1端口绑定5.2域名绑定5.2.1域名概念5.2.2域名级别5.2.3域名与ip绑定6.Nginx反向代理6.1反向代理概念6.2配置反向代理7.Nginx负载均衡7.1负载均衡概念7.2准备工作7.3配置负载均衡Nginx1.Nginx概念    Nginx是⼀款高性能的http服务器/反向代理服务器及电子

  • mysql数据库cap理论_CAP理论总结

    mysql数据库cap理论_CAP理论总结C代表Consistency,一致性,是指所有节点在同一时刻的数据是相同的,即更新操作执行结束并响应用户完成后,所有节点存储的数据会保持相同。A代表Availability,可用性,是指系统提供的服务一直处于可用状态,对于用户的请求可即时响应。P代表PartitionTolerance,分区容错性,是指在分布式系统遇到网络分区的情况下,仍然可以响应用户的请求。网络分区是指因为网…

  • linux命令行与shell脚本编程大全和鸟哥的私房菜_linux进入命令行

    linux命令行与shell脚本编程大全和鸟哥的私房菜_linux进入命令行一、基本bashshell命令创建文件:touch链接文件:符号链接:是一个实实在在的文件,两个通过符号链接在一起的文件,彼此的内容并不相同。使用ln-s命令。硬链接:会创建独立的虚拟文件,其中包含了原始文件的信息及位置。但他们从根本上而言是同一个文件。原始文件必须事先存在,使用ln命令。查看文件类型:file查看整个文件:cat,more,less…

发表回复

您的电子邮箱地址不会被公开。

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