#!/bin/bash
#前缀路径
PREFIX="/usr/local/dip/xxx"
#客户端名称,必须是和logtail根目录下路径名一致
CLIENTNAME="default"
#关闭
stop(){
cd $PREFIX/$CLIENTNAME
$PREFIX/$CLIENTNAME/stopClient.sh && echo "Stop dip_scribe_client $CLIENTNAME Successful!" || echo "Stop dip_scribe_client $CLIENTNAME Failed!"
echo
}
#启动
start(){
cd $PREFIX/$CLIENTNAME
$PREFIX/$CLIENTNAME/startClient.sh && echo "Start dip_scribe_client $CLIENTNAME Successful!"
echo
}
#状态
status(){
pid=`ps -ef | grep $PREFIX/$CLIENTNAME/dip_scribe_client |grep -v 'grep' | awk '{print $2}'`
#打印PID
echo "dip_scribe_client $CLIENTNAME - $pid"
}
if [ -z $2 ];then
echo $CLIENTNAME
else
CLIENTNAME=$2
fi
case "$1" in
start)
echo "Start dip_scribe_client $CLIENTNAME"
echo
start
echo
;;
stop)
echo "Stop dip_scribe_client $CLIENTNAME"
echo
stop
echo
;;
restart)
echo "Restart dip_scribe_client $CLIENTNAME"
echo
stop
start
echo
;;
status)
echo "Pid of dip_scribe_client $CLIENTNAME"
status
echo
;;
*)
echo $"Usage: $0 {start|stop|restart|status} [CLIENTNAME]"
exit 1
;;
esac
命名为dip_scribe_client 并拷贝到/etc/init.d/下,并赋予755权限
service dip_scribe_client start [clientname]