#!/bin/bash

cwd=`pwd`

# 引入全局文件
source ${cwd}/bin/global.sh
# 清空日志
#rm -rf logs/*.log
#rm -rf logs/*/2022*.log
# 清空日志
echo $cwd
module=$1

function stopserver()
{
    echo "Begin stop module $1..."
    for i in `ps -ef | grep -w $1/${GLOBAL_SERVICE_NAME_PREFIX}$1 | grep -v grep | awk '{print $2}'`
    do
        echo "$1 process $i"
        echo "kill -${2} $i"
        kill -${2} $i
    done

    # 杀死进程
     pkill -${2} -f "${1}/.*${1}"

    echo "Stop module $1 End"
}

stopserver $module 2
sleep 5

  stopserver central 9
  stopserver logic 9
  stopserver world 9
  stopserver gateway 9
  stopserver mapsearch 9
  stopserver chat 9
  stopserver report 9
  sleep 3

stopserver login 2
sleep 2
stopserver login 9
stopserver gm 2
sleep 2
stopserver gm 9
stopserver version 2
sleep 2
stopserver version 9
stopserver pay 2
sleep 2
stopserver pay 9
stopserver fight 2
sleep 2
stopserver fight 9
 

# 查看所有进程
WatchAllServices
