Skip to content

Instantly share code, notes, and snippets.

@coolswitcher
Created August 29, 2015 14:39
Show Gist options
  • Save coolswitcher/584a509ae8f6bc777735 to your computer and use it in GitHub Desktop.
Save coolswitcher/584a509ae8f6bc777735 to your computer and use it in GitHub Desktop.
searchd init script for ubuntu/debian
#! /bin/bash
### BEGIN INIT INFO
# Provides: searchd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start searchd daemon
# Description: Start up searchd, sphinx search daemon
### END INIT INFO
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
pidfile=/run/sphinx/searchd.pid
binpath=/usr/local/bin/searchd
SPHINX="--config /etc/sphinxsearch/sphinx.conf"
NAME=searchd
DESC="sphinx search daemon"
test -f $binpath || exit 0
set -e
. /lib/lsb/init-functions
case "$1" in
start)
echo "Starting sphinx search daemon: searchd"
start-stop-daemon --start --quiet --chuid 999 --group 999 --exec $binpath -- $SPHINX
echo "."
;;
stop)
echo "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 "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 "."
;;
status)
status_of_proc -p $pidfile "${binpath}" "searchd"
;;
*)
echo "Usage: /etc/init.d/sphinx {start|stop|restart|force-reload|status}"
exit 1
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment