#!/bin/bash

SERVER=`pwd | awk -F/ '{print $4}'`

if [ "${SERVER}" == "" ]
then
        echo "path error!"
        exit 1
fi

PID=`ps aux | grep logic | grep -v grep | grep ${SERVER} | awk '{print $2}'`

if [ "${PID}" != "" ]
then
        echo "Stopping ${SERVER} logic..."
        kill ${PID}
		sleep 2
		
		ENGINE_PID=`ps aux | grep logic | grep -v grep | grep ${SERVER} | awk '{print $2}'`
		if [ "${ENGINE_PID}" == "" ]
		then
			echo "kill ${SERVER} logic ok!"
		fi
		
else
		echo "No ${SERVER} logic process found, exits."
        exit 1
fi
