How did I configure `pt-kill` as a daemon on Debian?

mysql
(Dmitry Fedyuk) #1

/etc/init.d/pt-kill:

#!/bin/sh

### BEGIN INIT INFO
# Provides:          pt-kill
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts pt-kill
# Description:       starts pt-kill
### END INIT INFO

# 2019-07-01 Dmitry Fedyuk https://www.upwork.com/fl/mage2pro
# https://blog.bramp.net/post/2012/09/30/pt-kill-centos-init.d-script

. /lib/lsb/init-functions

RETVAL=0

# See how we were called.
case "$1" in
  start)
    echo -n $"Starting pt-kill: "

    pt-kill \
      --busy-time 60 \
      --daemonize \
      --database fmb \
      --interval 5 \
      --log /var/log/_my/pt-kill.log \
      --kill \
      --password m5GUfRot \
      --pid /var/run/pt-kill.pid \
      --user root \
      --wait-after-kill 15

    RETVAL=$?
    echo
    [ $RETVAL -ne 0 ] && exit $RETVAL

  ;;
  stop)
        # Stop daemons.
        echo -n $"Shutting down pt-kill: "
        pkill -f pt-kill
        rm -f /var/run/pt-kill.pid
        echo
    ;;
  restart)
    $0 stop
        $0 start
        ;;
  *)
        echo $"Usage: pt-kill {start|stop}"
        RETVAL=3
        ;;
esac

exit $RETVAL
0 Likes