Veerasundaravel's Ruby on Rails Weblog

June 20, 2008

Sphinx startup script related to sphinx installtion

Continuing my last post Installing sphinx – https://veerasundaravel.wordpress.com/2008/06/20/installing-sphinx-in-linux-environment/

Here the startup script for the sphinx search engine.

#! /bin/sh
# /etc/init.d/sphinx: start the sphinx search daemon.

PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin

pidfile=/var/sphinx/run/searchd.pid
binpath=/var/sphinx/bin/searchd

SPHINX=”–config /var/sphinx/etc/sphinx.conf”

NAME=searchd
DESC=”sphinx search daemon”

test -f $binpath || exit 0

test ! -r /etc/default/sphinx || . /etc/default/sphinx

running()
{
# No pidfile, probably no daemon present
#
if [ ! -f $pidfile ]
then
return 1
fi

pid=`cat $pidfile`

# No pid, probably no daemon present
#
if [ -z “$pid” ]
then
return 1
fi

if [ ! -d /proc/$pid ]
then
return 1
fi

cmd=`cat /proc/$pid/cmdline | tr “00” “\n”|head -n 1`

# No syslogd?
#
if [ “$cmd” != “$binpath” ]
then
return 1
fi

return 0
}

case “$1” in
start)
echo -n “Starting sphinx search daemon: searchd”
start-stop-daemon –start –quiet –chuid 999 –group 999  –exec $binpath — $SPHINX
echo “.”
;;
stop)
echo -n “Stopping sphinx search daemon: searchd”
start-stop-daemon –stop –chuid 999 –group 999 –retry TERM/1/TERM/1/TERM/4/KILL –quiet –exec $binpath –pidfile $pidfile
echo “.”
;;
restart|force-reload)
echo -n “Restarting sphinx search daemon: searchd”
start-stop-daemon –stop –chuid 999 –group 999  –retry TERM/1/TERM/1/TERM/4/KILL –quiet –exec $binpath –pidfile $pidfile
start-stop-daemon –start –chuid 999 –group 999  –quiet –exec $binpath — $SPHINX
echo “.”
;;
*)
echo “Usage: /etc/init.d/shpinx {start|stop|restart|force-reload}”
exit 1
esac

exit 0

Advertisements

1 Comment »

  1. Undeniably believe that which you stated. Your favorite justification appeared to be on the net the easiest thing to
    be aware of. I say to you, I certainly get
    irked while people think about worries that they just
    don’t know about. You managed to hit the nail upon the top and also defined out the whole
    thing without having side-effects , people could take a signal.
    Will likely be back to get more. Thanks

    Comment by http://www.mercsminis.com/Forums/index.php?action=profile&u=502832 — September 6, 2013 @ 1:14 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: