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
48 daemon --user $user --redirfds \
49 /usr/bin/pt-kill --config $config --daemonize --pid $pidfile --sentinel $sentinel "$dsn"
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
56 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pt-kill
60 if [ ! -f /var/lock/subsys/pt-kill ]; then
61 msg_not_running "pt-kill"
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
73 if [ ! -f /var/lock/subsys/pt-kill ]; then
74 msg_not_running "pt-kill"
84 # See how we were called.
103 status --pidfile $pidfile pt-kill
107 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"