mirror of https://github.com/MISP/misp-dashboard
chg: [startup] Wait until redis is ready before starting the zmqs
scriptspull/121/head
parent
19842f9445
commit
3e218cd145
25
start_all.sh
25
start_all.sh
|
@ -6,6 +6,29 @@ GREEN="\\033[1;32m"
|
||||||
DEFAULT="\\033[0;39m"
|
DEFAULT="\\033[0;39m"
|
||||||
RED="\\033[1;31m"
|
RED="\\033[1;31m"
|
||||||
|
|
||||||
|
function wait_until_redis_is_ready {
|
||||||
|
redis_not_ready=true
|
||||||
|
while $redis_not_ready; do
|
||||||
|
if checking_redis; then
|
||||||
|
redis_not_ready=false;
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e $GREEN"* Redis 6250 is running"$DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
|
function checking_redis {
|
||||||
|
flag_redis=0
|
||||||
|
bash -c 'redis-cli -p 6250 PING | grep "PONG" &> /dev/null'
|
||||||
|
if [ ! $? == 0 ]; then
|
||||||
|
echo -e $RED"Redis 6250 not ready"$DEFAULT
|
||||||
|
flag_redis=1
|
||||||
|
fi
|
||||||
|
sleep 0.1
|
||||||
|
return $flag_redis;
|
||||||
|
}
|
||||||
|
|
||||||
# Getting CWD where bash script resides
|
# Getting CWD where bash script resides
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
DASH_HOME="${DIR}"
|
DASH_HOME="${DIR}"
|
||||||
|
@ -61,6 +84,8 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
|
wait_until_redis_is_ready;
|
||||||
|
|
||||||
if [ "${check_dashboard_port}" == "1" ]; then
|
if [ "${check_dashboard_port}" == "1" ]; then
|
||||||
echo -e $GREEN"\t* Launching flask server"$DEFAULT
|
echo -e $GREEN"\t* Launching flask server"$DEFAULT
|
||||||
${ENV_PY} ./server.py &
|
${ENV_PY} ./server.py &
|
||||||
|
|
12
start_zmq.sh
12
start_zmq.sh
|
@ -20,19 +20,11 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
PID_SCREEN=$(screen -ls | grep ${SCREEN_NAME} | cut -f2 | cut -d. -f1)
|
PID_SCREEN=$(screen -ls | grep ${SCREEN_NAME} | cut -f2 | cut -d. -f1)
|
||||||
if [[ $PID_SCREEN ]]; then
|
if [[ $PID_SCREEN ]]; then
|
||||||
echo -e $RED"* A screen '$SCREEN_NAME' is already launched"$DEFAULT
|
echo -e $RED"* A screen '$SCREEN_NAME' is already launched"$DEFAULT
|
||||||
echo "Would you like to restart it (y/n)? "
|
echo -e $GREEN"Killing $PID_SCREEN"$DEFAULT;
|
||||||
read answer
|
kill $PID_SCREEN
|
||||||
if [ "$answer" != "${answer#[Yy]}" ] ;then
|
|
||||||
echo -e $GREEN"Killing $PID_SCREEN"$DEFAULT;
|
|
||||||
kill $PID_SCREEN
|
|
||||||
else
|
|
||||||
echo 'Exiting'
|
|
||||||
exit 0;
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo 'No screen detected'
|
echo 'No screen detected'
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue