TestRoots/watchdog

View on GitHub
server/init.d/watchdog

Summary

Maintainability
Test Coverage
#! /bin/sh
# /etc/init.d/watchdog
#
#
#
### BEGIN INIT INFO
# Provides:          watchdog 
# Required-Start:    $network $local_fs $remote_fs
# Required-Stop:     $network $local_fs $remote_fs
# Should-Start:      $named
# Should-Stop:
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: WatchDog Server 
# Description:       WatchDog Server is the mongo-backed WatchDog data collection backend 
#
### END INIT INFO
wdserver="/mnt/data/watchdog/git-repo-server/server"

# Some things that run always
touch /var/lock/watchdog

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    echo "Starting watchdog server with supervise"
    sudo -u testroots bash --login -c 'cd ${wdserver} && supervise .' &
    ;;
  stop)
    echo "Stopping watchdog server"
    sudo -u testroots bash --login -c 'cd ${wdserver} && svc -dx . && ./stop' 
     ;;
  *)
    echo "Usage: /etc/init.d/watchdog {start|stop}"
    exit 1
    ;;
esac

exit 0