Skip to content
Snippets Groups Projects
Commit abb895e4 authored by Wojciech Barcik's avatar Wojciech Barcik
Browse files

Better script for starting hive server

parent 18a27559
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!340Switch back to old gitlab ci executor
#!/bin/bash
# TODO This script needs review.
set -euo pipefail
HIVEMIND_PID=0
......@@ -9,16 +11,27 @@ START_DELAY=5
# For debug only!
# HIVED_URL='{"default":"http://hived-node:8091"}'
# HIVED_URL='{"default":"http://172.17.0.1:8091"}'
# HIVED_URL='{"default":"http://127.0.0.1:8091"}'
# HIVEMIND_HTTP_PORT="8080"
# HIVEMIND_POSTGRESQL_CONNECTION_STRING="postgresql://syncad:devdev@localhost:5432/hive_test"
check_pid() {
if [ -f hive_server.pid ]; then
HIVEMIND_PID=`cat hive_server.pid`
if ps -p $HIVEMIND_PID > /dev/null
then
# Process is running
echo "Process pid $HIVEMIND_PID is running"
else
# Process is not running
rm hive_server.pid
HIVEMIND_PID=0
fi
else
HIVEMIND_PID=0
fi
}
stop() {
if [ "$HIVEMIND_PID" -gt "0" ]; then
HIVEMIND_PID=`cat hive_server.pid`
......@@ -61,16 +74,34 @@ start() {
for i in `seq 1 10`; do
if [ -f hive_server.pid ]; then
echo "Hive server has been started (pid $HIVEMIND_PID)"
echo "Starting hive server (pid $HIVEMIND_PID)"
# Wait some time to allow its initialization.
sleep $START_DELAY
exit 0
# Check if process is still running.
if ps -p $HIVEMIND_PID > /dev/null
then
echo "Hive server is running (pid $HIVEMIND_PID)"
exit 0
else
# Check if process executed successfully or not.
if wait $HIVEMIND_PID; then
echo "Hive server has been started (pid $HIVEMIND_PID)"
exit 0
else
RESULT=$?
echo "Hive server terminated abnormally (returned $RESULT)"
rm hive_server.pid;
exit $RESULT
fi
fi
else
sleep 1
fi
done
# If we are here something went wrong
# If we are here, something went wrong.
echo "Timeout reached. Hive server has not been started, exiting."
rm hive_server.pid;
exit 1
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment