I am running Stardog 4.0 in an Ubuntu 15.04 container with open jdk8, which is working fine. I want to handle gracefully closing the stardog using a trap.
To execute stardog in a container so that it continues to work, I used the following, which works well
$SBIN/bin/stardog-admin server start && (tail -f /storage/stardog.log &) && while (pidof java > /dev/null); do sleep 1; done
Without the following, the container will run for several seconds and stop
&& (tail -f /storage/stardog.log &) && while (pidof java > /dev/null); do sleep 1; done
However, this results in multiple PIDs in the container
root 1 0.0 0.0 18384 3236 ? Ss 14:04 0:02 /bin/bash /stardog_binaries/startup.sh
root 45 0.1 4.9 4619052 406940 ? Sl 14:04 0:10 java -Xms2g -Xmx2g -XX:MaxDirectMemorySize=4g -XX:SoftRefLRUPolicyMSPerMB=1 -XX:+UseParallelOldGC -XX:+UseCompressedOops -Djavax.xml.datatype.DatatypeFactory=org.apache.xerc
root 97 0.0 0.0 4412 740 ? S 14:04 0:00 tail -f /storage/stardog.log
root 12108 0.2 0.0 18184 3100 ? Ss 15:44 0:00 bash
root 12122 0.0 0.0 4376 784 ? S 15:44 0:00 sleep 1
And the following trap does not work to turn off stardog when closing the container
trap 'kill -TERM $PID' TERM INT
$SBIN/bin/stardog-admin server start && (tail -f /storage/stardog.log &) && while (pidof java > /dev/null); do sleep 1; done
PID=$!
wait $PID
trap - TERM INT
wait $PID
EXIT_STATUS=$?
So, my question is how to correctly capture the start of the $ SBIN / bin / stardog-admin server so that when the container is closed, it will fail due to an elegant exit.
Relations Conte