]> git.pld-linux.org Git - packages/percona-toolkit.git/blame - pt-kill.init
- drop obsolete and outdated manual inclusion of rpm macros
[packages/percona-toolkit.git] / pt-kill.init
CommitLineData
a207031c
ER
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.
17if 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
22else
23 exit 0
24fi
25
26config=/etc/percona-toolkit/pt-kill.conf
9a55bcde
ER
27sentinel=/var/run/percona-toolkit/pt-kill.sentinel
28pidfile=/var/run/percona-toolkit/pt-kill.pid
29user=percona-toolkit
210a69e2
ER
30# use "empty" DSN, so it uses my.cnf settings
31dsn=';'
a207031c
ER
32
33# Get service config - may override defaults
34[ -f /etc/sysconfig/pt-kill ] && . /etc/sysconfig/pt-kill
35
36start() {
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
016f37e7 46 # use RC_LOGGING=no, because we need to escape ";" from shell
bfd200a0 47 # NOTE: disable --redirfds to be able to see connect errors
016f37e7 48 RC_LOGGING=no \
349c5c33 49 daemon --user $user --redirfds \
210a69e2 50 /usr/bin/pt-kill --config $config --daemonize --pid $pidfile --sentinel $sentinel "$dsn"
a207031c 51 RETVAL=$?
349c5c33
ER
52
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
56
a207031c
ER
57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/pt-kill
58}
59
60stop() {
61 if [ ! -f /var/lock/subsys/pt-kill ]; then
62 msg_not_running "pt-kill"
63 return
64 fi
65
66 # Stop daemons.
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
71}
72
73condrestart() {
74 if [ ! -f /var/lock/subsys/pt-kill ]; then
75 msg_not_running "pt-kill"
76 RETVAL=$1
77 return
78 fi
79
80 stop
81 start
82}
83
84RETVAL=0
85# See how we were called.
86case "$1" in
87 start)
88 start
89 ;;
90 stop)
91 stop
92 ;;
93 restart)
94 stop
95 start
96 ;;
97 try-restart)
98 condrestart 0
99 ;;
100 force-reload)
101 condrestart 7
102 ;;
103 status)
104 status --pidfile $pidfile pt-kill
105 RETVAL=$?
106 ;;
107 *)
108 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
109 exit 3
110esac
111
112exit $RETVAL
This page took 0.081244 seconds and 4 git commands to generate.