#!/bin/bash

_dir=$(cd "$(dirname "$0")"; pwd)
echo "`date "+%F %T"` User:`whoami` begin to stop flume ..... "

FLUME_PID=`ps -ef | grep "${_dir}" |grep flume-ng |grep -v grep | grep -v stopFlume | awk '{print $2}'`
if [ "${FLUME_PID}k" != "k" ];then
    echo "flume begin to stop and pid is:${FLUME_PID} 。。。"
    kill -9 ${FLUME_PID} &&  cd ${_dir} &&  /bin/rm -rf  checkpoint0 checkpoint1 checkpoint2 data0 data1 data2 conf/taildir_position_s0.json conf/taildir_position_s1.json conf/taildir_position_s2.json
    if [ $? == 0 ];then
        echo  "`date "+%F %T"` flume stop finished"
    else
        echo  "`date "+%F %T"` flume stop error"
    fi
fi

exit 0
