sphinx加入到centos服务的脚本

sphinx加入到centos服务的脚本

#gedit /etc/init.d/myservice
#!/bin/sh
# chkconfig: 2345 10 90
# description: myservice ....
#/www/wdlinux/sphinx/bin/
#mashengwang@qq.com

sphinx_pidfile=/www/wdlinux/sphinx/bin/searchd.pid
if [ -e "${sphinx_pidfile}"   ] ; then
	sphinx_active=1  #runing
	#echo ${sphinx_active}
else
	sphinx_active=0   #close 
	#echo ${sphinx_active}
fi

stop(){
if [  "${sphinx_active}" -eq 0 ];then
	echo -e '\e[31m SPHINX  Has been turned off  \e[m' #红色
	exit 1
else
	/www/wdlinux/sphinx/bin/searchd   --config  /www/wdlinux/sphinx/etc/www_muslimwww.conf --stop   > /dev/null 2>&1 
        resu=$?
        if [  "${resu}" -eq 0  ];  then
             echo -e '\e[32m******************************************************************** \e[m' #绿色
		echo -e '\e[32m( ^_^ ) Sphinx stop SUCESS( ^_^ ) \e[m' #绿色
	     echo -e '\e[32m******************************************************************** \e[m' #绿色
        else
             echo -e '\e[31m******************************************************************** \e[m' #红色
		echo -e '\e[31m !o(︶︿︶)o!Sphinx stop FAIL! ~~~~(>_<)~~~~ \e[m' #红色
	     echo -e '\e[31m******************************************************************** \e[m' #红色
        fi
	return ${resu}
fi
}

start(){
if [  "${sphinx_active}" -eq 1 ];then
	echo -e '\e[31m SPHINX  Is already running  \e[m' #红色
	exit 1
else
	/www/wdlinux/sphinx/bin/searchd  --config  /www/wdlinux/sphinx/etc/www_muslimwww.conf > /dev/null 2>&1 
       resu=$?
        if [  "${resu}" -eq 0  ];  then
             echo -e '\e[32m******************************************************************** \e[m' #绿色
		echo -e '\e[32m ( ^_^ )Sphinx start SUCESS( ^_^ ) \e[m' #绿色
	     echo -e '\e[32m******************************************************************** \e[m' #绿色
        else
              echo -e '\e[31m******************************************************************** \e[m' #红色
	        echo -e '\e[31m !o(︶︿︶)o!Sphinx start FAIL! ~~~~(>_<)~~~~ \e[m' #红色
	     echo -e '\e[31m******************************************************************** \e[m' #红色

        fi
	return ${resu}
fi
}

indexer_all(){
if [  "${sphinx_active}" -eq 0 ];then
	echo -e '\e[31m SPHINX  Has been turned off  \e[m' #红色
	exit 1
else

	/usr/local/sphinx/bin/indexer --config  /www/wdlinux/sphinx/etc/www_muslimwww.conf    --all > /dev/null 2>&1
	resu=$?
        if [  "${resu}" -eq 0  ];  then
             echo -e '\e[32m******************************************************************** \e[m' #绿色
		echo -e '\e[32m ( ^_^ )Sphinx indexer_all SUCESS( ^_^ ) \e[m' #绿色
	     echo -e '\e[32m******************************************************************** \e[m' #绿色
        else
              echo -e '\e[31m******************************************************************** \e[m' #红色
	        echo -e '\e[31m  !o(︶︿︶)o!Sphinx indexer_all FAIL! ~~~~(>_<)~~~~ \e[m' #红色
	     echo -e '\e[31m******************************************************************** \e[m' #红色

        fi
        return ${resu}
fi
}

indexer_online(){
if [  "${sphinx_active}" -eq 0 ];then
	echo -e '\e[31m SPHINX  Has been turned off  \e[m' #红色
	exit 1
else
	/usr/local/sphinx/bin/indexer --config  /www/wdlinux/sphinx/etc/www_muslimwww.conf   --rotate --all  > /dev/null 2>&1
	resu=$?
       if [  "${resu}" -eq 0  ];  then
             echo -e '\e[32m******************************************************************** \e[m' #绿色
		echo -e '\e[32m ( ^_^ )Sphinx indexer_online SUCESS( ^_^ ) \e[m' #绿色
	     echo -e '\e[32m******************************************************************** \e[m' #绿色
        else
              echo -e '\e[31m******************************************************************** \e[m' #红色
	        echo -e '\e[31m  !o(︶︿︶)o!Sphinx indexer_online FAIL! ~~~~(>_<)~~~~ \e[m' #红色
	     echo -e '\e[31m******************************************************************** \e[m' #红色

        fi
        return ${resu}
fi
}

status(){
if [  "${sphinx_active}" -eq 0 ];then
	echo -e '\e[31m SPHINX  Has been turned off  \e[m' #红色
	exit 1
else
        /www/wdlinux/sphinx/bin/searchd  --config  /www/wdlinux/sphinx/etc/www_muslimwww.conf --status
        resu=$?
        if [  "${resu}" -eq 0  ];  then
        #echo "sphinx status ok"
        echo -e '\e[32m******************************************************************** \e[m' #绿色
        echo -e '\e[32m ( ^_^ )Sphinx status ok( ^_^ ) \e[m' #绿色
        echo -e '\e[32m******************************************************************** \e[m' #绿色
        else
         #echo "sphinx status unknow"
        echo -e '\e[31m*********************************************************************  \e[m' #红色
        echo -e '\e[31m  !o(︶︿︶)o!Sphinx  status unknown ~~~~(>_<)~~~~  \e[m' #红色
        echo -e '\e[31m********************************************************************* \e[m' #红色
        fi
        return ${resu}
fi
}

case $1 in
	restart)
	stop
	start
	;;

	stop)
	stop
	;;
	
	start)
	start
	;;

	indexer_all)
	indexer_all
	;;

	indexer_online)
	indexer_online
	;;

	status)
        status
        ;;

esac

exit 0

加入服务脚本:

cp sphinx /etc/init.d/

chmod 755 /etc/init.d/sphinx

chkconfig --add sphinx

service sphinx restart



  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值