Bug #11157
Improve FWD server startup mode in server.sh
100%
Related issues
History
#1 Updated by Andrei Plugaru 6 months ago
While working on #4369, I discovered that the current way of starting the Java process in server.sh may not work well when the deployment is inside a docker container. The exact problem is when the docker container is stopped and the entrypoint is server.sh, the KILL signal will be not be forwarded to the FWD server, meaning the process will be forcefully killed without allowing the execution of the shutdown hooks.
The solution to that is explained in #4369-97. I will post a patch here for server.sh for hotel gui in order to be reviewed.
#2 Updated by Andrei Plugaru 6 months ago
- Related to Feature #4369: implement stateless FWD server clustering added
#3 Updated by Andrei Plugaru 6 months ago
- Status changed from New to WIP
- reviewer Roger Borrello added
This is the patch needed for server.sh in hotel_gui project which allows redirecting the KILL signal to the java process:
=== modified file 'deploy/server/server.sh' --- old/deploy/server/server.sh 2026-01-29 12:19:06 +0000 +++ new/deploy/server/server.sh 2026-01-30 10:14:47 +0000 @@ -148,6 +148,14 @@ cdsparams="${xshare} ${xxsharedarchive} ${xxdumploaded} ${xxsharedclass} ${xlog}" } +# Handler to forward the kill signal to the FWD server +shutdown_handler() +{ + kill -SIGTERM "$pid" + + wait "$pid" +} + show_usage() { i=0; usage[$i]="\nUsage: $0 [-dyptksw1a] [-o<path>] [-m{1|0}] [-b<process>] [-z<cp>] [-h<heap>] [-c<cfg>] [-i<instance>] [-r<profile>] [-j<jar>] @@ -322,12 +330,17 @@ ensure_utf8_lang # run the FWD server +JAVA_CMD="$prog $dump $perf $hprof $maxheap $srvr $jmx $dtxt $agent $spi $open_api $cpath $cdsparams $entrypoint $mode $batch $cfg $port $profile" if [ $test -eq 1 ] ; then - echo $prog $dump $perf $hprof $maxheap $srvr $jmx $dtxt $agent $spi $open_api $cpath $cdsparams $entrypoint $mode $batch $cfg $port $profile "$@" + echo "$JAVA_CMD" "$@" elif [ $statcode = "y" ]; then - $prog $dump $perf $hprof $maxheap $srvr $jmx $dtxt $agent $spi $open_api $cpath $cdsparams $entrypoint $mode $batch $cfg $port $profile "$@" 2> /dev/null + $JAVA_CMD "$@" 2> /dev/null else - eval $prog $dump $perf $hprof $maxheap $srvr $jmx $dtxt $agent $spi $open_api $cpath $cdsparams $entrypoint $mode $batch $cfg $port $profile "$@" $output_redir + trap 'shutdown_handler' SIGTERM SIGINT + eval $JAVA_CMD "$@" $output_redir \& + pid=$! + + wait "$pid" fi rc=$?
I have also did some small refactoring in that area as the command to start the process was repeated 3 times, I extracted it in a separate variable.
Roger, please take a look!
#5 Updated by Roger Borrello 6 months ago
The changes look very good. Have you tested start_server.sh, the a wrapper script that expects server.sh to start in the background, and returns status of its launch?
#7 Updated by Roger Borrello 6 months ago
- Status changed from Review to Internal Test
- Assignee set to Andrei Plugaru
- % Done changed from 0 to 100
Can you test with Hotel ChUI, as well? If testing is good, Greg, we should be able to merge to the Hotel projects. It can also be a candidate for any customer projects exhibiting the same issues that brought on the need for this change. But I don't know that it would need to be done proactively if there isn't an issue with the customers.