You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
Bash
68 lines
1.7 KiB
Bash
#!/bin/bash
|
|
#
|
|
# This script is designed to handle various operations related to setting up, starting, stopping the python application
|
|
# It will assume the requirements file is at the root (not with the source code)
|
|
#
|
|
|
|
export PYTHONPATH=$PWD/src
|
|
pip_upgrade='sandbox/bin/pip freeze|sort |diff requirements.txt -|grep \<|grep -E " .+$" -o'
|
|
install(){
|
|
|
|
virtualenv sandbox
|
|
sandbox/bin/pip install -r requirements.txt
|
|
`sandbox/bin/pip freeze|sort |diff requirements.txt -|grep \<|grep -E " .+$" -o|sandbox/bin/pip install --upgrade`
|
|
|
|
|
|
}
|
|
register(){
|
|
curl -X POST https://the-phi.com/store/init/monitor-logs -H "uid:$1" -H"pid: $2"
|
|
|
|
|
|
|
|
}
|
|
upgrade(){
|
|
git pull
|
|
count=`sandbox/bin/pip freeze|sort |diff requirements.txt -|grep \<|grep -E " .+$" -o|wc -l`
|
|
if [ ! "$count" = "0" ]; then
|
|
`sandbox/bin/pip freeze|sort |diff requirements.txt -|grep \<|grep -E " .+$" -o|sandbox/bin/pip install --upgrade`
|
|
else
|
|
echo "No Upgrade required for sandbox"
|
|
fi
|
|
|
|
}
|
|
start(){
|
|
|
|
sandbox/bin/python src/utils/agents/data-collector.py --path $PWD/config.json
|
|
|
|
}
|
|
stop(){
|
|
ps -eo pid,command|grep python|grep -E "$PWD"|grep data-collector|grep -E "^ {0,}[0-9]+" -o |xargs kill -9
|
|
}
|
|
|
|
status(){
|
|
pid=`ps -eo pid,command|grep python|grep -E "$PWD"|grep index.py|grep -E "^ {0,}[0-9]+" -m 1 -o`
|
|
if [ "$pid" = "" ]; then
|
|
echo "API IS OFFLINE"
|
|
else
|
|
echo "API IS ONLINE $pid"
|
|
fi
|
|
pid=`ps -eo pid,command|grep python|grep -E "$PWD"|grep data-collector|grep -E "^ {0,}[0-9]+" -m 1 -o`
|
|
if [ "$pid" = "" ]; then
|
|
echo "DATA-COLLECTOR IS OFFLINE"
|
|
else
|
|
echo "DATA-COLLECTOR IS ONLINE $pid"
|
|
fi
|
|
|
|
}
|
|
|
|
if [ "$1" = "start" ]; then
|
|
if [ "$2" = "collector" ]; then
|
|
start "collector"
|
|
else
|
|
start
|
|
fi
|
|
else
|
|
$1
|
|
|
|
fi
|