steelThread / redmon

A web interface for managing redis: cli, admin, and live monitoring
http://steelthread.github.com/redmon/
1.57k stars 127 forks source link

has anyone done a init.d service wrapper? #81

Closed SteveDevOps closed 8 years ago

SteveDevOps commented 8 years ago

has anyone been able to do a init.d service wrapper for this? running under screen for now on centos 6.7

SteveDevOps commented 8 years ago

nevermind we solved with:

#!/bin/sh
#
# chkconfig: 2345 90 60
#
# description: Simple Redmon init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
PID=$(ps -efH | grep [/]usr/local/rvm/gems/ruby-2.3.0/bin/redmon | grep ruby | awk '{ print $2}')
case "$1" in
    start)
        if [ ! -z  $PID ]
        then
                echo "$PID exists, process is already running or crashed"
                kill -2 $PID
                echo "Redmon stopped"
                echo "Starting Redmon..."
                /bin/su - redisdaemon -c "redmon &"
        else
                echo "Starting Redmon..."
                /bin/su - redisdaemon -c "redmon &"
        fi
        ;;
    stop)
        if [ -z $PID ]
        then
                echo "$PID does not exist, process is not running"
        else
                echo "Stopping ..."
                kill -2 $PID
                echo "Redmon stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac