summaryrefslogtreecommitdiff
path: root/system/rabbitmq-server/rc.rabbitmq
blob: 9f6715bcc224b48e34f63d561d52f65387d0fe08 (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
#!/bin/sh
# Start/stop/restart Rabbit MQ daemon

USER=rabbitmq
DAEMON_START_OPTS="-detached"

rabbitmq_start(){
	sudo -u ${USER} sh -c "/usr/bin/rabbitmq-server ${DAEMON_START_OPTS}"
}

rabbitmq_stop() {
	sudo -u ${USER} sh -c "/usr/bin/rabbitmqctl stop"
}

rabbitmq_restart() {
	rabbitmq_stop
	sleep 1
	rabbitmq_start
}

rabbitmq_status() {
	sudo -u ${USER} sh -c "/usr/bin/rabbitmqctl status"
}

print_usage() {
	echo "usage $0 start|stop|restart|status"
}

case "$1" in
	'start')
		rabbitmq_start
	      	;;
	'stop')
		rabbitmq_stop
	      	;;
	'restart')
		rabbitmq_restart
	      	;;
	'status')
		rabbitmq_status
		;;
	*)
		print_usage
		;;
esac