fix(server): fix foreground mode exit code propagation in startup scripts#3044
Open
bitflicker64 wants to merge 1 commit into
Open
fix(server): fix foreground mode exit code propagation in startup scripts#3044bitflicker64 wants to merge 1 commit into
bitflicker64 wants to merge 1 commit into
Conversation
The previous implementation captured $! after the daemon/foreground if/else block. The script blocked at hugegraph-server.sh until Java exited, then $! was empty, the pid file got an empty string, and the script exited 0, losing Java's exit code entirely. Fix: move all post-branch logic inside the DAEMON == "true" branch. In the foreground branch, background Java with &, capture $!, write the pid file, then wait $PID and exit $? so Java's exit code propagates out. Gate OPEN_MONITOR inside the daemon branch since monitor setup after a blocking foreground call makes no sense. Also fix restserver.url in rest-server.properties to include the http:// scheme prefix, which was causing URL parsing issues in util.sh. Add test-start-hugegraph.sh to verify baseline and post-fix behavior, and wire it into server-ci.yml for the RocksDB backend. related to : apache#3043
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3044 +/- ##
============================================
- Coverage 35.96% 34.47% -1.49%
Complexity 338 338
============================================
Files 803 803
Lines 68053 68053
Branches 8907 8907
============================================
- Hits 24472 23462 -1010
- Misses 40955 42025 +1070
+ Partials 2626 2566 -60 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix foreground mode in
start-hugegraph.sh(chunk 1 of #3043)Problem
In foreground mode (
-d false),start-hugegraph.shhad a structuralbug: all post-branch logic ran unconditionally after the daemon/foreground
if/elseblock.In foreground mode the script blocks at
hugegraph-server.shuntil Javaexits. After Java exits:
PID="$!"captures an empty string (no background job)bin/pidis written with an empty stringwait_for_startupfails immediately (empty PID, Java already dead)disownfails (no background jobs)OPEN_MONITORfires unconditionally — even in foreground modeThis means a Java crash in foreground mode is invisible to the process
supervisor (Docker restart policy, systemd, etc.).
Fix
PID="$!", pid file write,trap,wait_for_startup,disown,OPEN_MONITOR) inside theDAEMON == "true"branch where it belongs.&, capture$!,write the pid file, then
wait $PID(so the script blocks while Javaruns) and
exit $?(so Java's exit code propagates out).OPEN_MONITORinside the daemon branch — monitor setup after ablocking foreground call makes no sense.
Also included
restserver.urlinrest-server.propertiesto include thehttp://scheme prefix (was127.0.0.1:8080, nowhttp://127.0.0.1:8080). Thecheck_portand URL parsing inutil.shexpect a full URL.Tests
New script:
hugegraph-server/hugegraph-dist/src/assembly/travis/test-start-hugegraph.sh-m trueregisters cron in daemon modeWired into
server-ci.ymlafter the Compile step, rocksdb backend only(foreground mode behavior is backend-independent).
What this does NOT include
Docker entrypoint changes and runtime restart validation (kill Java
inside container → container exits → Docker restarts it) are in the
follow-up PR for chunks 4–8.
Relates to #3043 (chunk 1 of 3 startup script fixes)