Project

General

Profile

Bug #11157

Improve FWD server startup mode in server.sh

Added by Andrei Plugaru 6 months ago. Updated 6 months ago.

Status:
Internal Test
Priority:
Normal
Assignee:
Andrei Plugaru
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

Related issues

Related to Database - Feature #4369: implement stateless FWD server clustering Test

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!

#4 Updated by Andrei Plugaru 6 months ago

  • Status changed from WIP to Review

#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?

#6 Updated by Andrei Plugaru 6 months ago

Roger Borrello wrote:

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?

I tested start_server.sh now and it seems fine.

#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.

#8 Updated by Greg Shah 6 months ago

In a perfect world, the same server.sh would be used at all customers. I don't want it to be customized or be out of date. SO: plan to apply the change everywhere.

#9 Updated by Andrei Plugaru 6 months ago

Roger Borrello wrote:

Can you test with Hotel ChUI, as well?

I tested now and it is also fine. If we want to apply the change to other projects, I guess it would be best to create a task in Regression Testing project where to handle the testing.

Also available in: Atom PDF