Skip to content

Commit

Permalink
Add SIGTERM handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ryn5 committed Dec 12, 2023
1 parent c2e2086 commit 9ed65cb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion gremlin-server/src/main/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
handler()
{
kill -s SIGINT "$PID"
}

exec $GREMLIN_SERVER "$@" &
PID=$(ps aux | grep -w $GREMLIN_SERVER | grep -v grep | awk '{print $1}')
trap 'handler $PID' SIGTERM
wait "$PID"

0 comments on commit 9ed65cb

Please sign in to comment.