is_exist
if [ $? -eq "0" ]
then
echo "${APP_NAME} is running now. pid=${pid}."
return 0
else
echo "failed to start ${APP_NAME}! see ${APP_LOG} for more details."
return 1
fi
fi
}
# 停止HelloWorld进程
stop()
{
is_exist
if [ $? -eq 0 ]
then echo "try to stop ${APP_NAME} ..."
# 调用kill命令杀掉进程
/usr/bin/kill -9 ${pid}
if [ $? -ne 0 ]
then echo "failed to stop ${APP_NAME}!"
return 1
else
echo "${APP_NAME} stopped."
return 0
fi
else
echo "${APP_NAME} is not running!"
return 1
fi
}
# 重启HelloWorld进程
restart(){
stop
start
}
# 显示帮助信息
help()
{
echo "status show the status of ${APP_NAME} server."
echo "start start the ${APP_NAME} server."
echo "stop stop the ${APP_NAME} server."
echo "restart restart the ${APP_NAME} server."
}
# 主函数
main()
{
case "$1" in
status) status;;
start) start;;
stop) stop;;
restart) restart;;
*) echo "command param error ! see follow help "; help;;
esac
}
# 执行主函数 $1表示选择第一个字符串为参数,比如终端命令是:./run.sh start status,则选择start为输入参数
main $1