close(client_fd);
exit(0);
}
close(client_fd);
}
return 0;
}
调用shell 服务器端
#!/bin/sh
Project_name=$1
Command=$2
my_Back="webapps_backup"
case "$Command" in
start)
export Java_HOME=/usr/local/java/jdk1.6.0_23
cd $Project_name
rm -rf work/*
$Project_name/bin/startup.sh >/dev/null
sleep 3
tompid=`ps -ef|grep $Project_name|grep -v "grep"|grep -v "$0" |awk '{print $2}'`
if ( [ -n "$tompid" ] );then
echo -e "\033[32m$Project_name启动成功\033[0m"
else
echo -e "\033[31m$Project_name启动失败,请重新执行一次命令\033[0m"
fi
;;
stop)
pidlist=`ps -ef|grep $Project_name|grep -v "grep"|grep -v "$0" |awk '{print $2}'`
#echo "tomcat Id list :$pidlist"
kill -15 $pidlist
#echo "KILL $pidlist"
sleep 10
tompid=`ps -ef|grep $Project_name|grep -v "grep"|grep -v "$0" |awk '{print $2}'`
if ( [ -n "$tompid" ] && [ $tompid == $pidlist ] );then
echo -e "\033[31m$Project_name停止失败,请重新执行一次命令\033[0m"
else
#/usr/bin/tail -1000 $Project_name/logs/catalina.out
echo -e "\033[32m$Project_name停止成功\033[0m"
fi
;;
status)
tompid=`ps -ef|grep $Project_name|grep -v "grep"|grep -v "$0" |awk '{print $2}'`
if ( [ -n "$tompid" ] );then
echo -e "\033[32m$Project_name运行中......\033[0m"
else
echo -e "\033[32m$Project_name停止中.....\033[0m"
fi
;;
restart)
export JAVA_HOME=/usr/local/java/jdk1.6.0_23
pidlist=`ps -ef|grep $Project_name|grep -v "grep"|grep -v "$0"|awk '{print $2}'`
# echo "tomcat Id list :$pidlist"
kill -15 $pidlist
#echo "KILL $pidlist:"
#echo "stop success"
#echo "start tomcat"
cd $Project_name
rm -rf work/*