summaryrefslogtreecommitdiff
path: root/packaging/debs/Debian/debian/init.d
blob: f3999888452a8aca63fad3ecbfd98c165179115d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh
### BEGIN INIT INFO
# Provides:          rabbitmq
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Enable AMQP service provided by RabbitMQ.
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/rabbitmq-multi
NAME=rabbitmq-server
DESC=rabbitmq-server
USER=rabbitmq
NODE_COUNT=1

test -x $DAEMON || exit 0

# Include rabbitmq defaults if available
if [ -f /etc/default/rabbitmq ] ; then
	. /etc/default/rabbitmq
fi

set -e
cd /

start_rabbitmq () {
      set +e
      su rabbitmq -s /bin/sh -c "$DAEMON start_all ${NODE_COUNT}" > /var/log/rabbitmq/startup.log 2> /var/log/rabbitmq/startup.err
      case "$?" in
        0)
          echo SUCCESS;;
        1)
          echo TIMEOUT - check /var/log/rabbitmq/startup.\{log,err\};;
        *)
          echo FAILED - check /var/log/rabbitmq/startup.log, .err
          exit 1;;
      esac 
      set -e
}

stop_rabbitmq () {
    set +e
    su rabbitmq -s /bin/sh -c "$DAEMON stop_all" > /var/log/rabbitmq/shutdown.log 2> /var/log/rabbitmq/shutdown.err
    if [ $? != 0 ] ; then
        echo FAILED - check /var/log/rabbitmq/shutdown.log, .err
        exit 0
    fi
    set -e
}

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start_rabbitmq
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	stop_rabbitmq
	echo "$NAME."
	;;
  force-reload|restart)
	echo -n "Restarting $DESC: "
	stop_rabbitmq
	start_rabbitmq
	echo "$NAME."
	;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0