Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
4.1 kB
3
Indexable
Never
#!/bin/bash
source ~/.bash_profile

setEnv () {
    LOC="$0"
    SCRIPT_HOME=$(dirname "$LOC")
    ANALYTICS_HOME=/app/server/tibenrichedODSDataConsumer
}

setEnv

# Exporting python path
export PYTHON_HOME=/app/software/binaries/python3.7.3
#export PYTHON_HOME=/home/hobapp/.local
echo $PYTHON_HOME
if [ -z ${PYTHON_HOME} ]; then
    echo -e "PYTHON_HOME variable not set.\nTerminating setup..."
    exit 1
fi;

echo "Starting Rest Data Services"
export PYTHONHOME=${PYTHON_HOME}
export ODSDATACONSUMERDEPLOYMENT=/app/server/tibenrichedODSDataConsumer/deployments
export ODSDATACONSUMERMSLOGPATH=/app/server/tibenrichedODSDataConsumer/logs
export ODSDATACONSUMERMSPATH=${PYTHONHOME}/lib/python3.7/site-packages/tibenrichedODSDataConsumer

echo "ODSDATACONSUMERDEPLOYMENT: $ODSDATACONSUMERDEPLOYMENT"
echo "ODSDATACONSUMERMSLOGPATH : $ODSDATACONSUMERMSLOGPATH"
echo "ODSDATACONSUMERMSPATH    : $ODSDATACONSUMERMSPATH"

ARTIFACT=$(find $ODSDATACONSUMERDEPLOYMENT -name *.whl | awk -F '/' '{print $NF}')
echo "ARTIFACT                 : $ARTIFACT"

runningprocess=`ps -ef  | grep 'tibenrichedODSDataConsumer/kafkaConsumerService.py' | grep 'python3' | awk '{print $2}'`
for i in $runningprocess
do
    `kill -9 $i`
done 

if [ -f ${ODSDATACONSUMERMSLOGPATH}/tibenrichedODSDataConsumer_console.log ]; then
    echo `mv $ODSDATACONSUMERMSLOGPATH/tibenrichedODSDataConsumer_console.log $ODSDATACONSUMERMSLOGPATH/tibenrichedODSDataConsumer_console.log.$(date "+%Y%m%d%H%M%S")`
else
    echo "Previous log not found. ${ODSDATACONSUMERMSLOGPATH}/tibenrichedODSDataConsumer_console.log"
fi;

process=$1
if [ "$process" == "setup" ]; then
    echo "Set up in progress"
    pip3 install $ODSDATACONSUMERDEPLOYMENT/$ARTIFACT
elif [ "$process" = "restart" ]; then
    echo "Restarting the service"
else
    echo "Argument setup or restart needs to be passed"
    exit 1
fi

python3.7 -m tibenrichedODSDataConsumer.start
echo "Checking for errors."
sleep 2
if [ -f ${ODSDATACONSUMERMSLOGPATH}/tibenrichedODSDataConsumer_console.log ]; then
    errCount=`grep -i "errno" $ODSDATACONSUMERMSLOGPATH/tibenrichedODSDataConsumer_console.log | wc -l`
    echo "Errors: ${errCount}"
    if [ ${errCount} -ge 1 ]; then
        echo `tail -10 $ODSDATACONSUMERMSLOGPATH/tibenrichedODSDataConsumer_console.log`
        echo "Error during startup."
        exit 1
    fi;
    echo "Service successfully started."
else
    echo "Service not started."
    exit 1
fi;
exit 0


for above one iam getting below error


[14:45] Gopi Peruboina

[14:44:22:ec2-user@ip-192-168-21-68 ] /app/server/tibenrichedODSDataConsumer/scripts>./startTibenrichedODSDataConsumer.sh setup

vm.max_map_count = 262144

/home/ec2-user/.local/lib/python3.7

Starting Rest Data Services

ODSDATACONSUMERDEPLOYMENT: /app/server/tibenrichedODSDataConsumer/deployments

ODSDATACONSUMERMSLOGPATH : /app/server/tibenrichedODSDataConsumer/logs

ODSDATACONSUMERMSPATH    : /home/ec2-user/.local/lib/python3.7/lib/python3.7/site-packages/tibenrichedODSDataConsumer

ARTIFACT                 : tibenrichedODSDataConsumer-9.0.2.88.13.42-py3-none-any.whl

Previous log not found. /app/server/tibenrichedODSDataConsumer/logs/tibenrichedODSDataConsumer_console.log

Set up in progress

Fatal Python error: initfsencoding: Unable to get the locale encoding

ModuleNotFoundError: No module named 'encodings'

 

Current thread 0x0000ffffb8ed1010 (most recent call first):

./startTibenrichedODSDataConsumer.sh: line 55:  4342 Aborted                 pip3 install $ODSDATACONSUMERDEPLOYMENT/$ARTIFACT

Fatal Python error: initfsencoding: Unable to get the locale encoding

ModuleNotFoundError: No module named 'encodings'

 

Current thread 0x0000ffff86fe0010 (most recent call first):

./startTibenrichedODSDataConsumer.sh: line 57:  4343 Aborted                 python3.7 -m tibenrichedODSDataConsumer.start

Checking for errors.

Service not started.

[14:44:26:ec2-user@ip-192-168-21-68 ] /app/server/tibenrichedODSDataConsumer/scripts>