PID_FILE=pid/malformedword.pid
CLASS_PATH=package/lib
MAIN_CLASS=com.youku.netty.HttpServer
echo "start? stop? restart? "
read key
case "$key" in
start)
if [ ! -f $PID_FILE ]; then
echo "server starting ..."
nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 &
echo $! > $PID_FILE
echo "server started"
else
echo "server is already started"
fi
;;
stop)
if [ -f $PID_FILE ]; then
PID=$(cat $PID_FILE);
echo "server stoping ..."
kill -9 $PID;
rm $PID_FILE
echo "server stoped"
else
echo "server is already stoped"
fi
;;
restart)
if [ -f $PID_FILE ]; then
PID=$(cat $PID_FILE);
echo "server stoping ..."
kill -9 $PID;
rm $PID_FILE
echo "server stoped"
echo "restart ..."
echo "server starting ..."
nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 &
echo $! > $PID_FILE
echo "server started"
else
echo "server starting ..."
nohup java -classpath "$CLASS_PATH/*" $MAIN_CLASS -server -Xms1g -Xmx8g -XX:NewSize=512m -Xss512k -XX:+UseConcMarkSweepGC -XX:+UseParNewGC > logs/server.log 2 >&1 &
echo $! > $PID_FILE
echo "server started"
fi
;;
esac
shell脚本示例,start stop restart
最新推荐文章于 2023-07-05 16:19:18 发布