updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / ruby-enterprise-stompserver / stompserver.rc.d
blob81272cbb5fc9d130373518a06e07d4e9fdcbf363
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 PID_FILE="/var/lib/stompserver/log/stompserver.pid"
8 check_pid() {
9 local PIDFILE="$1"
10 [ ! -f "$PIDFILE" ] && return 1
11 local PID=$(cat "$PIDFILE" 2> /dev/null)
12 [ -z "$PID" ] && return 1
13 if [ ! -d "/proc/$PID" ]; then
14 rm -f "$PIDFILE" 2> /dev/null
15 return 1
17 return 0
20 kill_pid() {
21 local PIDFILE="$1"
22 if check_pid "$PIDFILE"; then
23 local PID=$(cat "$PIDFILE" 2> /dev/null)
24 kill $PID &> /dev/null
25 local RET=$?
26 check_pid "$PIDFILE"
27 return $RET
29 return 1
32 wait_pid() {
33 while check_pid "$1"; do sleep 1; done
36 case "$1" in
37 start)
38 stat_busy "Starting stompserver"
39 check_pid "$PID_FILE" || /opt/ruby-enterprise/bin/stompserver -C /etc/stompserver.conf &> /dev/null
40 if [ $? -gt 0 ]; then
41 stat_fail
42 else
43 add_daemon git-daemon
44 stat_done
47 stop)
48 stat_busy "Stopping stompserver"
49 if ! kill_pid "$PID_FILE"; then
50 stat_fail
51 else
52 rm_daemon git-daemon
53 stat_done
56 restart)
57 $0 stop
58 sleep 1
59 wait_pid "$PID_FILE"
60 $0 start
63 echo "usage: $0 {start|stop|restart}"
64 esac
65 exit 0