]> git.pld-linux.org Git - packages/percona-toolkit.git/blob - pt-kill.init
05502876d70bf665f3772aba0fd4f9c5fca93855
[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/percona-toolkit/pt-kill.sentinel
28 pidfile=/var/run/percona-toolkit/pt-kill.pid
29 user=percona-toolkit
30 # use "empty" DSN, so it uses my.cnf settings
31 dsn=';'
32
33 # Get service config - may override defaults
34 [ -f /etc/sysconfig/pt-kill ] && . /etc/sysconfig/pt-kill
35
36 start() {
37         # Check if the service is already running?
38         if [ -f /var/lock/subsys/pt-kill ]; then
39                 msg_already_running "pt-kill"
40                 return
41         fi
42
43         msg_starting "pt-kill"
44         # FIXME: instead of removing, fix stop process
45         rm -f $sentinel
46         # use RC_LOGGING=no, because we need to escape ";" from shell
47         RC_LOGGING=no \
48         daemon --user $user --redirfds \
49                 /usr/bin/pt-kill --config $config --daemonize --pid $pidfile --sentinel $sentinel "$dsn"
50         RETVAL=$?
51
52         # workaround for lack of exit status check:
53         # https://bugs.launchpad.net/percona-toolkit/+bug/1314500
54         [ ! -f "$pidfile" -a $RETVAL = 0 ] && RETVAL=1
55
56         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pt-kill
57 }
58
59 stop() {
60         if [ ! -f /var/lock/subsys/pt-kill ]; then
61                 msg_not_running "pt-kill"
62                 return
63         fi
64
65         # Stop daemons.
66         msg_stopping "pt-kill"
67         run_cmd --user $user "pt-kill" /usr/bin/pt-kill --config $config --stop --sentinel $sentinel
68         # FIXME: wait for sentinel and remove it
69         rm -f /var/lock/subsys/pt-kill
70 }
71
72 condrestart() {
73         if [ ! -f /var/lock/subsys/pt-kill ]; then
74                 msg_not_running "pt-kill"
75                 RETVAL=$1
76                 return
77         fi
78
79         stop
80         start
81 }
82
83 RETVAL=0
84 # See how we were called.
85 case "$1" in
86   start)
87         start
88         ;;
89   stop)
90         stop
91         ;;
92   restart)
93         stop
94         start
95         ;;
96   try-restart)
97         condrestart 0
98         ;;
99   force-reload)
100         condrestart 7
101         ;;
102   status)
103         status --pidfile $pidfile pt-kill
104         RETVAL=$?
105         ;;
106   *)
107         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
108         exit 3
109 esac
110
111 exit $RETVAL
This page took 0.058544 seconds and 2 git commands to generate.