monde (owner)

Revisions

gist: 134718 Download_button fork
public
Public Clone URL: git://gist.github.com/134718.git
Bash
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
75
76
77
78
79
#! /bin/sh
# /etc/init.d/sphinx: start the sphinx search daemon.
 
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
 
PIDFILE=/opt/local/var/db/sphinx/log/searchd.pid
BINPATH=/usr/local/bin/searchd
 
SPHINX="--config /etc/sphinx/sphinx.conf"
 
NAME=searchd
DESC="sphinx search daemon"
 
test -f $BINPATH || exit 0
 
# Debian/Ubuntu style
# 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 "\000" "\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 www-data:www-data --exec $BINPATH -- $SPHINX
    echo "."
    ;;
  stop)
    echo -n "Stopping sphinx search daemon: searchd"
    start-stop-daemon --stop --chuid www-data:www-data --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $BINPATH --pidfile $PIDFILE
    #start-stop-daemon --stop --chuid www-data:www-data --retry TERM/1/TERM/1/TERM/4/KILL --pidfile $PIDFILE
    echo "."
    ;;
  restart|force-reload)
    echo -n "Restarting sphinx search daemon: searchd"
    start-stop-daemon --stop --chuid www-data:www-data --retry TERM/1/TERM/1/TERM/4/KILL --quiet --exec $BINPATH --pidfile $PIDFILE
    #start-stop-daemon --stop --chuid www-data:www-data --retry TERM/1/TERM/1/TERM/4/KILL --pidfile $PIDFILE
    start-stop-daemon --start --chuid www-data:www-data --quiet --exec $BINPATH -- $SPHINX
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/shpinx {start|stop|restart|force-reload}"
    exit 1
esac
 
exit 0