【实战】sphinx启动关闭管理脚本

WBOY
풀어 주다: 2016-06-07 16:10:56
원래의
1046명이 탐색했습니다.

#!/bin/sh#/usr/local/sphinx/bin/##ocpyang@126.comsphinx_pidfile=/usr/local/sphinx/var/log/searchd.pidif [ -e ${sphinx_pidfile} ] ; thensphinx_active=1 #runing#echo ${sphinx_active}elsesphinx_active=0 #close #echo ${sphinx_active}fistop(){i

#!/bin/sh
#/usr/local/sphinx/bin/
#
#ocpyang@126.com

sphinx_pidfile=/usr/local/sphinx/var/log/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
	/usr/local/sphinx/bin/searchd   --config  /usr/local/sphinx/etc/sphinx.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 &#39;\e[31m !o(︶︿︶)o!Sphinx stop FAIL! ~~~~(>_<)~~~~ \e[m&#39; #红色
	     echo -e &#39;\e[31m******************************************************************** \e[m&#39; #红色
        fi
	return ${resu}
fi
}



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

        fi
	return ${resu}
fi
}



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

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

        fi
        return ${resu}
fi
}



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

        fi
        return ${resu}
fi
}


status(){
if [  "${sphinx_active}" -eq 0 ];then
	echo -e &#39;\e[31m SPHINX  Has been turned off  \e[m&#39; #红色
	exit 1
else
        /usr/local/sphinx/bin/searchd  --config  /usr/local/sphinx/etc/sphinx.conf --status
        resu=$?
        if [  "${resu}" -eq 0  ];  then
        #echo "sphinx status ok"
        echo -e &#39;\e[32m******************************************************************** \e[m&#39; #绿色
        echo -e &#39;\e[32m ( ^_^ )Sphinx status ok( ^_^ ) \e[m&#39; #绿色
        echo -e &#39;\e[32m******************************************************************** \e[m&#39; #绿色
        else
         #echo "sphinx status unknow"
        echo -e &#39;\e[31m*********************************************************************  \e[m&#39; #红色
        echo -e &#39;\e[31m  !o(︶︿︶)o!Sphinx  status unknown ~~~~(>_<)~~~~  \e[m&#39; #红色
        echo -e &#39;\e[31m********************************************************************* \e[m&#39; #红色
        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
로그인 후 복사


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!