This is an automated email from the ASF dual-hosted git repository.

xiazcy pushed a commit to branch 3.6-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


The following commit(s) were added to refs/heads/3.6-dev by this push:
     new 1e10331e2c TINKERPOP-2950 Add docker shutdown handling to close 
containers gracefully (#2397)
1e10331e2c is described below

commit 1e10331e2c766d625f535797a1aec64943a28f08
Author: Ryan Tan <65996005+r...@users.noreply.github.com>
AuthorDate: Mon Dec 18 16:46:53 2023 -0800

    TINKERPOP-2950 Add docker shutdown handling to close containers gracefully 
(#2397)
    
    * Add SIGTERM handling
    
    * Update PID assignment to only take first result
    
    * Remove aux option
---
 gremlin-server/src/main/docker/docker-entrypoint.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/gremlin-server/src/main/docker/docker-entrypoint.sh 
b/gremlin-server/src/main/docker/docker-entrypoint.sh
index d869b8c2da..af7050cdad 100755
--- a/gremlin-server/src/main/docker/docker-entrypoint.sh
+++ b/gremlin-server/src/main/docker/docker-entrypoint.sh
@@ -22,10 +22,19 @@
 set -e
 
 CONF_FILE=$1
+GREMLIN_SERVER=/opt/gremlin-server/bin/gremlin-server.sh
 
 # IP substitution hack borrowed from:
 # 
https://github.com/htaox/NEAT/blob/94a004831cf89767e116d955192fc14ac82e5069/docker-scripts/gremlin-server-3.0.0/files/default_cmd#L5
 IP=$(ip -o -4 addr list eth0 | perl -n -e 'if (m{inet\s([\d\.]+)\/\d+\s}xms) { 
print $1 }')
 sed -i "s|^host:.*|host: $IP|" $CONF_FILE
 
-exec /opt/gremlin-server/bin/gremlin-server.sh "$@"
\ No newline at end of file
+handler()
+{
+  kill -s SIGINT "$PID"
+}
+
+exec $GREMLIN_SERVER "$@" &
+PID=$(ps | grep -w $GREMLIN_SERVER | grep -v grep | awk 'NR==1 {print $1}')
+trap 'handler $PID' SIGTERM
+wait "$PID"

Reply via email to