3 # pt-kill This shell script takes care of starting and stopping the pt-kill services.
7 # description: pt-kill stops long running MySQL queries
10 # Source function library
11 . /etc/rc.d/init.d/functions
14 . /etc/sysconfig/network
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"
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
30 # use "empty" DSN, so it uses my.cnf settings
33 # Get service config - may override defaults
34 [ -f /etc/sysconfig/pt-kill ] && . /etc/sysconfig/pt-kill
37 # Check if the service is already running?
38 if [ -f /var/lock/subsys/pt-kill ]; then
39 msg_already_running "pt-kill"
43 msg_starting "pt-kill"
44 # FIXME: instead of removing, fix stop process
46 # use RC_LOGGING=no, because we need to escape ";" from shell
47 # NOTE: disable --redirfds to be able to see connect errors
49 daemon --user $user --redirfds \
50 /usr/bin/pt-kill --config $config --daemonize --pid $pidfile --sentinel $sentinel "$dsn"
53 # workaround for lack of exit status check:
54 # https://bugs.launchpad.net/percona-toolkit/+bug/1314500
55 [ ! -f "$pidfile" -a $RETVAL = 0 ] && RETVAL=1
57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pt-kill
61 if [ ! -f /var/lock/subsys/pt-kill ]; then
62 msg_not_running "pt-kill"
67 msg_stopping "pt-kill"
68 run_cmd --user $user "pt-kill" /usr/bin/pt-kill --config $config --stop --sentinel $sentinel
69 # FIXME: wait for sentinel and remove it
70 rm -f /var/lock/subsys/pt-kill
74 if [ ! -f /var/lock/subsys/pt-kill ]; then
75 msg_not_running "pt-kill"
85 # See how we were called.
104 status --pidfile $pidfile pt-kill
108 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"