start.sh 1018 Bytes
#!/bin/sh

#配置读取
vars=`sed -n '/^pwd\|^python\|^php\|^log_file/s/ \{1,\}= \{1,\}/=/p' Config.lua`
eval $vars

if [ ! -f "$log_file" ];then
		dir=`dirname $log_file`
		if [ ! -d $dir ];then
			mkdir -p $dir
		fi
        touch $log_file
        chmod 777 $log_file
fi

monitor(){
        #pid=`ps aux|grep $1.php|$wc -l`
        pid=`ps aux|grep "$1"|wc -l`

        if [ $pid -le 1 ];then
                msg="At time: `date` :$1  is stop ."
                echo $msg
                echo $msg >> $log_file
                #cmd="$php -f $pwd/$1.php"
                cmd="$1"
                echo $cmd
                echo $cmd >> $log_file
                $cmd 2>&1 &
        else
                echo "$1 is running ."
        fi
}

while true;do

        #http mq
        #monitor "$php -f $pwd/HttpMqServer.php"

        #mqclient
        #monitor "$python $pwd/MqClient.py"
        monitor "$python $pwd/GoMqClient.py"

        #xhprof.io
        #monitor "$php -f $pwd/MqXhprof.php"

        sleep 5

done