#!/bin/bash

ulimit -c unlimited -n 8192

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 "Process logic ${SERVER} exists, exit"
        exit 1
fi

echo "Start pokemon logic..."
nohup ./logic ${SERVER} > nohup.logic.out &

sleep 4
if ps aux | grep logic | grep --color=always ${SERVER} 
then
	echo "Game server start ok! ${SERVER} "
fi
