bitflicker64 opened a new pull request, #3047:
URL: https://github.com/apache/hugegraph/pull/3047

   Fix foreground mode in start-hugegraph-pd.sh and start-hugegraph-store.sh 
(chunks 2–3 of #3043)  
     
   ## Purpose of the PR  
     
   - relates to #3043  
     
   ## Main Changes  
     
   **Problem**  
     
   Both `start-hugegraph-pd.sh` and `start-hugegraph-store.sh` had no 
foreground  
   branch — the scripts always backgrounded Java with `exec ... &`, wrote `$!` 
to  
   the pid file, and exited 0, losing Java's exit code entirely. Docker/systemd 
 
   supervisors never saw a non-zero exit, so containers were never restarted on 
 
   Java crash.  
     
   **Fix**  
     
   Add `DAEMON="true"` default and `-d true|false` flag to getopts in both 
scripts.  
   Daemon branch keeps `exec ... &` with `$!` as before. Foreground branch 
writes  
   `$$` to the pid file **before** `exec` (exec replaces the shell with Java, 
so  
   `$$` == Java's PID after exec), then `exec java` without `&` so the process  
   blocks and Java's exit code propagates out directly.  
     
   No trap needed in the foreground branch — `exec` replaces the shell process 
with  
   Java, so signals from Docker/systemd go directly to Java without a wrapper 
to  
   forward through (unlike chunk 1 where `& + wait` required an explicit trap). 
 
     
   **Tests**  
     
   | Script | Test file | Tests | Baseline | After fix |  
   |---|---|---|---|---|  
   | `start-hugegraph-pd.sh` | `test-start-hugegraph-pd.sh` | 4 (daemon 
regression, foreground blocks, exit code 137, SIGTERM 143) | 3 passed, 9 failed 
| 12 passed, 0 failed |  
   | `start-hugegraph-store.sh` | `test-start-hugegraph-store.sh` | 4 (same) | 
3 passed, 5 failed | 11 passed, 0 failed |  
     
   Both test scripts wired into `pd-store-ci.yml` (no backend guard needed — 
pd/store jobs always run).  
     
   Note: Store health check is skipped when PD is not running — handled 
gracefully with a warning, not a failure.  
     
   **What's NOT in this PR**  
     
   Docker entrypoints, HEALTHCHECK, and cron monitor removal are in chunks 4–8 
(separate PR).  
     
   ## Verifying these changes  
     
   - [x] Need tests and can be verified as follows:  
       - `test-start-hugegraph-pd.sh $PD_DIR` — 12 assertions, all pass after 
fix  
       - `test-start-hugegraph-store.sh $STORE_DIR` — 11 assertions, all pass 
after fix  
     
   ## Does this PR potentially affect the following parts?  
     
   - [ ] Dependencies  
   - [ ] Modify configurations  
   - [ ] The public API  
   - [ ] Other affects  
   - [x] Nope  
     
   ## Documentation Status  
     
   - [x] `Doc - No Need`


-- 
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]

Reply via email to