-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_screen.sh
executable file
·45 lines (37 loc) · 1.28 KB
/
start_screen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env bash
#set -x
GREEN="\\033[1;32m"
DEFAULT="\\033[0;39m"
RED="\\033[1;31m"
# Getting CWD where bash script resides
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DASH_HOME="${DIR}"
SCREEN_NAME="Snake_Oil_Crypto_Window"
cd ${DASH_HOME}
#if [ -e "${DIR}/sage-8.9/local/bin/python" ]; then
if [ -e "${DIR}/SageMath/local/bin/python3" ]; then
echo "Sage virtualenv seems to exist."
ENV_LAUNCH="sage --python3 ${DIR}/SageMath/local/bin/rq worker"
else
echo "Please make sure you have a sage environment installed, exiting."
exit 1
fi
PID_SCREEN=$(screen -ls | grep ${SCREEN_NAME} | cut -f2 | cut -d. -f1)
if [[ $PID_SCREEN ]]; then
echo -e $RED"* A screen '$SCREEN_NAME' is already launched"$DEFAULT
echo -e $GREEN"Killing $PID_SCREEN"$DEFAULT;
kill $PID_SCREEN
else
echo 'No screen detected'
fi
screen -dmS ${SCREEN_NAME}
ps auxw |grep 'rq worker' |grep -v grep ; check_rq_worker=$?
sleep 0.1
if [ "${check_rq_worker}" == "1" ]; then
echo -e $GREEN"\t* Launching rq worker"$DEFAULT
screen -S ${SCREEN_NAME} -X screen -t "Worker-1" bash -c "${ENV_LAUNCH};"
screen -S ${SCREEN_NAME} -X screen -t "Worker-2" bash -c "${ENV_LAUNCH};"
screen -S ${SCREEN_NAME} -X screen -t "Worker-3" bash -c "${ENV_LAUNCH};"
else
echo -e $RED"\t* Worker seems to be already running."$DEFAULT
fi