OpenGrok§
To run the OpenGrok code search engine using Unit:
Install Unit with a Java 11+ language module.
Follow the official OpenGrok installation guide. Here, we’ll place the files at
/path/to/app/
:$ mkdir -p /path/to/app/{src,data,dist,etc,log} $ tar -C /path/to/app/dist --strip-components=1 -xzf opengrok-X.Y.Z.tar.gz
Our servlet container is Unit so we can repackage the
source.war
file to an arbitrary directory at Step 2:$ opengrok-deploy -c /path/to/app/etc/configuration.xml \ /path/to/app/dist/lib/source.war /path/to/app/
The resulting pathname is
/path/to/app/source.war
.Set installation path permissions to secure access, for example:
# chown -R app_user:app_group /path/to/app/
Update the placeholders above with actual values, noting them for later use in Unit configuration.
Next, put together the OpenGrok configuration for Unit:
{ "listeners": { "*:80": { "pass": "applications/opengrok" } }, "applications": { "opengrok": { "type": "java", "user": "app_user", "group": "app_group", "webapp": "/path/to/app/source.war", "options": [ "-Djava.awt.headless=true" ] } } }
Upload the updated configuration. Assuming the JSON above was added to
config.json
:# curl -X PUT --data-binary @config.json --unix-socket \ /path/to/control.unit.sock http://localhost/config/
Note
The control socket path may vary; run unitd --help or see Startup and Shutdown for details.
After a successful update, OpenGrok should be available on the listener’s IP address and port: