#!/bin/sh
#
# chkconfig: 345 99 01
# description: maxwell
#
# File : maxwell
#
# Description: Starts and stops the maxwell server
#
source /etc/rc.d/init.d/functions
source /etc/profile
MAXWELL_HOME=/usr/local/webserver/maxwell-1.22.0/
MAXWELL_CONF=$MAXWELL_HOME/maxwell_test.properties
MAXWELL_PORT=9082
MAXWELL_LOG=/data/logs/maxwell-logs/maxwelllogs.log
#MAXWELL_PID=$MAXWELL_HOME/RUNNING_PID
MAXWELL_USER=root
start(){
[ -x $MAXWELL_HOME ] || exit 5
echo -n "Starting maxwell-xc: "
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
if [ ! -z $PID ];then
echo -e " [\033[32m ok \033[0m]"
retval=$?
return $retval
elif [ ! -x $MAXWELL_PID ];then
rm -rf $MAXWELL_PID
fi
/sbin/runuser -s /bin/sh $MAXWELL_USER -c "$MAXWELL_HOME/bin/maxwell --bootstrapper=sync --config=$MAXWELL_CONF >>$MAXWELL_LOG 2>&1 &"
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
if [ -z $PID ];then
echo -e " [\033[32m ok \033[0m]"
retval=$?
else
echo -e " [\033[31m Fail \033[0m]"
alsss >/dev/null 2>&1
retval=$?
fi
#[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop(){
[ -x $MAXWELL_HOME ] || exit 5
echo -n "Stopping maxwell-xc: "
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
for i in $(seq 10)
do
if [ $i -eq "10" ];then
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
fi
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'|xargs kill -9`
if [ -z $PID ];then
echo -e " [\033[32m ok \033[0m]"
break
fi
sleep 1
done
retval=$?
#[ $retval -eq 0 ] && touch $lockfile
return $retval
}
status(){
echo -n "Maxwell-xc is "
PID=`ps aux|grep maxwell|grep $MAXWELL_CONF|grep -v grep |awk '{print \$2}'`
if [ -z $PID ];then
echo 'Stopped.'
else
echo "running $PID...."
fi
exit 0
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
maxwell 启动脚本
最新推荐文章于 2024-06-27 00:39:50 发布