forked from twitter/twemproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nutcracker.init
83 lines (71 loc) · 1.43 KB
/
nutcracker.init
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
80
81
82
#! /bin/sh
#
# chkconfig: - 55 45
# description: Twitter's twemproxy nutcracker
# processname: nutcracker
# config: /etc/sysconfig/nutcracker
# Source function library.
. /etc/rc.d/init.d/functions
USER="nobody"
OPTIONS="-d -c /etc/nutcracker/nutcracker.yml"
if [ -f /etc/sysconfig/nutcracker ];then
. /etc/sysconfig/nutcracker
fi
# Check that networking is up.
if [ "$NETWORKING" = "no" ]
then
exit 0
fi
RETVAL=0
prog="nutcracker"
start () {
echo -n $"Starting $prog: "
#Test the config before start.
daemon --user ${USER} ${prog} $OPTIONS -t >/dev/null 2>&1
RETVAL=$?
if [ $RETVAL -ne 0 ] ; then
echo "Config check fail! Please use 'nutcracker -c /etc/nutcracker/nutcracker.yml' for detail."
echo_failure;
echo;
exit 1
fi
daemon --user ${USER} ${prog} $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/${prog}
}
stop () {
echo -n $"Stopping $prog: "
killproc ${prog}
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/${prog}
fi
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status ${prog}
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/nutcracker ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $?