This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
/
sphinx
executable file
·74 lines (63 loc) · 2 KB
/
sphinx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /bin/sh
### BEGIN INIT INFO
# Provides: searchd
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the sphinx search server
# Description: starts sphinx search server using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
APPLICATION_PATH=
APPLICATION_ENV=
DAEMON=/usr/local/bin/searchd
INDEXER=/usr/local/bin/indexer
if [ "$APPLICATION_PATH" = "" ]; then
APPLICATION_PATH=$(readlink -f "$0" | xargs dirname | xargs dirname)/application
fi
if [ "$APPLICATION_ENV" = "" ]; then
if [ "$2" != "" ]; then
APPLICATION_ENV=$2
else
APPLICATION_ENV=production
fi
fi
export APPLICATION_ENV;
CONFIG=$APPLICATION_PATH/configs/sphinx.conf
PID=$(dirname $APPLICATION_PATH)/data/logs/sphinx-searchd.pid
test -x $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting searchd (env: $APPLICATION_ENV)..."
start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- --config $CONFIG
echo "Done."
;;
stop)
echo -n "Stopping searchd (env: $APPLICATION_ENV)..."
start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 --pidfile $PID --exec $DAEMON
echo "Done."
;;
restart|force-reload)
echo -n "Restarting searchd (env: $APPLICATION_ENV)..."
start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 --pidfile $PID --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- --config $CONFIG
echo "Done."
;;
index-all)
echo "Starting indexer (env: $APPLICATION_ENV)..."
if [ -e $PID ] ; then
$INDEXER --config $CONFIG --all --rotate
else
$INDEXER --config $CONFIG --all
fi
echo "Done."
;;
*)
echo "Usage: $0 start|stop|restart|force-reload|index-all [env]" >&2
exit 1
;;
esac
exit 0