#!/bin/bash
cwd=`pwd`
moduleid=$1
host=$2

#检查本地的进程
if [ $host == "127.0.0.1" ];then
    echo $moduleid
    ids=`ps aux| grep $moduleid | grep -v grep | grep -v killmoduleid | awk '{print $2}'`
    echo $ids
    if [ $ids ];then
        kill -9 $ids
        exit 1
    else
        exit 0
    fi
#检查远程的进程
else
    exist=`ssh $host "cd $cwd;bash $cwd/bin/killmoduleid_remote.sh $moduleid"`
    if [ ! $exist ];then
        exit 0
    else 
        exit 1
    fi
fi