Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions quarkus/dist/src/main/content/bin/kc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,14 @@ if [ "$PRINT_ENV" = "true" ]; then
echo "Using JAVA_RUN_OPTS: $JAVA_RUN_OPTS"
fi

eval "'$JAVA'" "$JAVA_RUN_OPTS"
status=$?
# trap the signals that should be forwarded to the java process
trap 'status=143; while [ -z "$PID" ]; do sleep 0.1; done; kill -TERM $PID; wait $PID' TERM INT
# run the java process in the background using the current stdin
eval "{ '$JAVA' $JAVA_RUN_OPTS <&3 3<&- & } 3<&0"
# obtain the pid, and await the exit status
PID=$!; wait $PID; status=$?
# remove the trap as signals can be directly handled
trap - TERM INT
# only exit code 10 means that implicit reaugmentation occurred and a relaunch is needed
if [ $status = 10 ]; then
JAVA_RUN_OPTS="-Dkc.config.built=true $JAVA_RUN_OPTS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ void noErrorSpiBuildtimeNotChanged(KeycloakDistribution dist) {
cliResult.assertNoError("The following build time options");
}

@Test
@RawDistOnly(reason = "Containers are immutable")
void terminateStartOptimized(KeycloakDistribution dist) {
CLIResult cliResult = dist.run("build", "--db=dev-file");
cliResult.assertBuild();

dist.setManualStop(true);
cliResult = dist.run("start", "--optimized", "--http-enabled=true", "--hostname-strict=false");
cliResult.assertStarted();

// if the child java process does not clean up, then subsequent start will fail
dist.stop();

cliResult = dist.run("start", "--optimized", "--http-enabled=true", "--hostname-strict=false");
cliResult.assertStarted();
}

@DryRun
@Test
@Launch({ "--profile=dev", "start", "--db=dev-file" })
Expand Down
Loading