Watchdog for Boa Web server

138 views Asked by At

I'm on a project where I use BOA web server, server crashes more at one point I wanted to make a good watchdog to reset it not that caught the process, most do not know where to start .. someone could help me?

1

There are 1 answers

0
Paulo Vagner On BEST ANSWER

I could solve my problem by using this code below:

#!/bin/sh
#chkconfig: 2345 90 10
#description: watchdog for myservice
#processname: myservice-watchdog

MYSERVICE_PID=`pidof /etc/init.d/apache2`

check_myservice() {
        if [ -z $MYSERVICE_PID ];then
                service apache2 start
        fi
}

check_myservice

usage() {
    echo "myservice-watchdog {start|stop|status}"
    exit 0
}

case $1 in
    start ) if [-z $MYSERVICE_PID ];then
        service apache2 start
        else
            echo "myservice is already running"
        fi
        ;;
    stop ) if [ -n $MYSERVICE_PID ];then
        service apache2 stop
        else
            echo "myservice is already stopped"
        fi
        ;;
    status) if [ -z $MYSERVICE_PID ];then
            echo "myservice is not running"
        else
            echo "myservice is running"
        fi
        ;;
    *) usage
        ;;
esac

But now I found another problem, this script ran perfectly .. but can not be used to identify the process PID, most have to use the process name.

Anyone know a way how I get the process name? rather to identify it?