source: npl/commonservers/daemontools/svcdownchk

Last change on this file was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100755
File size: 742 bytes
Line 
1#!/bin/bash
2# Stop a service and wait until it's really down
3SERVICE=$1
4TIMEOUT=$2
5
6if ! [ -e "$SERVICE/run" ]; then
7    exit 0
8fi
9
10if [ "$TIMEOUT" == "" ]; then
11    TIMEOUT=90
12fi
13
14svc -d $SERVICE
15sleep .1
16while ! svstat $SERVICE | grep ': down' >/dev/null; do
17    svc -d $SERVICE
18    if [ "$TIMEOUT" == "0" ]; then
19        exit 1
20    fi
21    ((TIMEOUT--))
22    #with 30 seconds left, we send an interupt.
23    #This is a forcefull shutdown without waiting for clients for most services
24    if [ "$TIMEOUT" == 30 ]; then
25        echo -n "sending interrupt "
26        svc -i $SERVICE
27    fi
28    #with 10 seconds lefts, we just kill it
29    if [ "$TIMEOUT" == 10 ]; then
30        echo -n "KILLING "
31        svc -k $SERVICE
32    fi
33    sleep 1
34    echo -n "."
35done
36exit 0
Note: See TracBrowser for help on using the repository browser.