]> git.pld-linux.org Git - packages/percona-toolkit.git/blob - pt-kill.init
2ac38415180b2c3529744e81dac0d5c754b0d785
[packages/percona-toolkit.git] / pt-kill.init
1 #!/bin/sh
2 #
3 # pt-kill       This shell script takes care of starting and stopping the pt-kill services.
4 #
5 # chkconfig:    345 60 40
6 #
7 # description: pt-kill stops long running MySQL queries
8 # processname:  pt-kill
9
10 # Source function library
11 . /etc/rc.d/init.d/functions
12
13 # Get network config
14 . /etc/sysconfig/network
15
16 # Check that networking is up.
17 if is_yes "${NETWORKING}"; then
18         if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
19                 msg_network_down "pt-kill"
20                 exit 1
21         fi
22 else
23         exit 0
24 fi
25
26 config=/etc/percona-toolkit/pt-kill.conf
27 sentinel=/var/run/pt-kill/pt-kill.sentinel
28 pidfile=/var/run/pt-kill/pt-kill.pid
29 user=root
30
31 # Get service config - may override defaults
32 [ -f /etc/sysconfig/pt-kill ] && . /etc/sysconfig/pt-kill
33
34 start() {
35         # Check if the service is already running?
36         if [ -f /var/lock/subsys/pt-kill ]; then
37                 msg_already_running "pt-kill"
38                 return
39         fi
40
41         msg_starting "pt-kill"
42         # FIXME: instead of removing, fix stop process
43         rm -f $sentinel
44         daemon --user $user --redirfds /usr/bin/pt-kill --config $config --daemonize --pid $pidfile --sentinel $sentinel
45         RETVAL=$?
46         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pt-kill
47 }
48
49 stop() {
50         if [ ! -f /var/lock/subsys/pt-kill ]; then
51                 msg_not_running "pt-kill"
52                 return
53         fi
54
55         # Stop daemons.
56         msg_stopping "pt-kill"
57         run_cmd --user $user "pt-kill" /usr/bin/pt-kill --config $config --stop --sentinel $sentinel
58         # FIXME: wait for sentinel and remove it
59         rm -f /var/lock/subsys/pt-kill
60 }
61
62 condrestart() {
63         if [ ! -f /var/lock/subsys/pt-kill ]; then
64                 msg_not_running "pt-kill"
65                 RETVAL=$1
66                 return
67         fi
68
69         stop
70         start
71 }
72
73 RETVAL=0
74 # See how we were called.
75 case "$1" in
76   start)
77         start
78         ;;
79   stop)
80         stop
81         ;;
82   restart)
83         stop
84         start
85         ;;
86   try-restart)
87         condrestart 0
88         ;;
89   force-reload)
90         condrestart 7
91         ;;
92   status)
93         status --pidfile $pidfile pt-kill
94         RETVAL=$?
95         ;;
96   *)
97         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
98         exit 3
99 esac
100
101 exit $RETVAL
This page took 0.061739 seconds and 2 git commands to generate.