#!/bin/bash

SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
thanos_dir=$(dirname "$SCRIPT_DIR")
user='store'
module='store'
log_dir="logs/thanos-${module}.log"

pid=`ps -ef | grep -w "${thanos_dir}/thanos[[:space:]]*${module}" | grep -v 'grep' | awk '{print $2}'`
if [ ! -n "$pid" ];then
  echo "error: !!!Thanos-${module} server not running!!!"
  exit 10
fi

if [ "`whoami`" != "${user}" ];then
  echo "error: !!!Excute user not ${user}!!!"
  exit 10
fi

kill -s QUIT $pid
sleep 2
ps -ef | grep -w "${thanos_dir}/thanos[[:space:]]*${module}" | grep -v 'grep' &>/dev/null
if [ $? -ne 0 ];then
  echo "success: Thanos-${module} process exit"
else
  echo "error: !!!Thanos-${module} process exit failed!!!"
  exit 10
fi



