【實戰】sphinx啟動關閉管理指令碼,sphinx指令碼

來源:互聯網
上載者:User

【實戰】sphinx啟動關閉管理指令碼,sphinx指令碼

#!/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(){if [  "${sphinx_active}" -eq 0 ];thenecho -e '\e[31m SPHINX  Has been turned off  \e[m' #紅色exit 1else/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 '\e[31m !o(︶︿︶)o!Sphinx stop FAIL! ~~~~(>_<)~~~~ \e[m' #紅色     echo -e '\e[31m******************************************************************** \e[m' #紅色        fireturn ${resu}fi}start(){if [  "${sphinx_active}" -eq 1 ];thenecho -e '\e[31m SPHINX  Is already running  \e[m' #紅色exit 1else/usr/local/sphinx/bin/searchd  --config  /usr/local/sphinx/etc/sphinx.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' #紅色        fireturn ${resu}fi}indexer_all(){if [  "${sphinx_active}" -eq 0 ];thenecho -e '\e[31m SPHINX  Has been turned off  \e[m' #紅色exit 1else/usr/local/sphinx/bin/indexer --config  /usr/local/sphinx/etc/sphinx.conf    --all > /dev/null 2>&1resu=$?        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 ];thenecho -e '\e[31m SPHINX  Has been turned off  \e[m' #紅色exit 1else/usr/local/sphinx/bin/indexer --config  /usr/local/sphinx/etc/sphinx.conf   --rotate --all  > /dev/null 2>&1resu=$?       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 ];thenecho -e '\e[31m SPHINX  Has been turned off  \e[m' #紅色exit 1else        /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 '\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 inrestart)stopstart;;stop)stop;;start)start;;indexer_all)indexer_all;;indexer_online)indexer_online;;status)        status        ;;esacexit 0


 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.