AvanishShukla20 opened a new pull request, #3253:
URL: https://github.com/apache/hugegraph/pull/3253
## Purpose of the PR
close #3236
Support running the PD, Store, and Server roles from read-only install
locations allowing their config, log, plugin, and PID paths to be redirected to
writable, externally-managed directories.
## Main Changes
### 1. Overridable runtime paths (start/stop/init scripts)
Added CLI override flags — each mapping to an environment variable with a
fallback to default:
| Concern | Flag | Variable | Fallback |
|---|---|---|---|
| Conf dir | `-c` | `CONF_OVERRIDE` | `$TOP/conf` |
| Logs dir | `-l` | `LOGS_OVERRIDE` | `$TOP/logs` |
| Plugins dir | `-o` | `PLUGINS_OVERRIDE` | `$TOP/plugins` |
| PID file | `-i` | `PID_FILE_OVERRIDE` | `$BIN/pid` |
- **Plugins (`-o`)** — The startup scripts validate it via
`ensure_path_writable` in `util.sh`, which fails fast if the path is not
writable. Script `init-store.sh` also honors `-o` , so the schema init uses
same plugins dir.
Also, files are written here at startup (OpenTelemetry agent download,
extension jars), so it should be writable.
- **PID file (`-i`)** — supervisors need the PID
file in a known, writable, per-instance location, and the **stop** scripts
must target the **same** PID the **start** scripts wrote. `-i` was added to
both start and stop scripts to keep them in agreement.
- Store/PD start scripts moved `getopts` **before** the path assignments so
the
overrides are actually applied (previously the option string omitted these
flags and/or paths were finalized before parsing).
- `exit_with_usage_help()` in `util.sh` and the inline usage strings were
updated to document the new flags.
### 2. Log4j2 / logging-config resolution fixes (start scripts)
Expanded `JVM_OPTIONS` across PD/Store/Server start scripts so logging is
resolved consistently:
```
-Dlog4j.configurationFile=${CONF}/log4j2.xml
-Dlog4j2.configurationFile=${CONF}/log4j2.xml
-Dlogging.config=${CONF}/log4j2.xml # Spring Boot picks up the intended
config
-DLOG_PATH=${LOGS} -Dbolt.log.path=${LOGS} -Dlogging.path=${LOGS}
```
- Added the missing `-Dlogging.config` so Spring Boot–based modules honor the
intended `log4j2.xml` .
- Store: fixed the GC log path to honor `${LOGS}` (which, if unset, falls
back
to `./logs` only) instead of a hardcoded `./logs/gc.log`.
- Fixed a line-break inside the `JVM_OPTIONS` string that previously split a
`-D` flag into an invalid bare argument.
### 3. `LOG_PATH` made overridable in all `log4j2.xml` files
Changed `log4j2.xml` files from a hardcoded `<property
name="LOG_PATH">logs</property>`
to:
```xml
<property name="LOG_PATH">${sys:LOG_PATH:-logs}</property>
```
so the log directory tracks the `-DLOG_PATH` set by the start scripts, and
can
also be set directly via `-DLOG_PATH=<dir>` when running a module jar (CLI,
tests, or embedded/standalone) without the start scripts. This spans the dist
`conf/` configs plus the `src/main` and `src/test` resources across PD,
Store,
and Server modules .
### How `LOG_PATH` resolves
Configs now converge on `${sys:LOG_PATH:-logs}` — the `LOG_PATH` **JVM
system property** (`-DLOG_PATH=<dir>`), falling back to relative `./logs`.
Overriding it is possible in three ways:
| Category | Files | Override mechanism |
|---|---|---|
| Dist / daemon `conf/` | pd/store/server `conf/log4j2.xml` | Start script
`-l <dir>` → `-DLOG_PATH=${LOGS}` |
| Test resources | `*/src/test/.../log4j2*.xml` | `mvn test
-DargLine="-DLOG_PATH=<dir>"` |
| Packaged jars | `*/src/main/.../log4j2*.xml` | `java -DLOG_PATH=<dir> -jar
<jar>` |
### Backward compatibility
Every override falls back to the previous default when its flag/variable is
not supplied, so existing standalone invocations and
packaging behave as before.
## Does this PR potentially affect the following parts?
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] Dependencies ([add/update
license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses)
info &
[regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh))
<!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both
in root & dist module) -->
- [x] Modify configurations
- [ ] The public API
- [ ] Other affects (typed here)
- [ ] Nope
## Documentation Status
Select one option and provide the documentation location when applicable.
- [ ] `Doc - TODO`: required documentation is pending; complete it before
merging.
- [ ] `Doc - Done`: documentation is included here or linked below.
- [x] `Doc - No Need`: no user-visible documentation is affected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]