-
Notifications
You must be signed in to change notification settings - Fork 0
/
pulsar
executable file
·112 lines (87 loc) · 1.73 KB
/
pulsar
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#! /bin/bash
# /etc/init.d/pulsar: start the pulsar daemon.
# chkconfig: - 80 20
# description: pulsar
PULSAR_START_SH="$PULSAR_HOME/bin/pulsar-daemon start standalone"
PULSAR_STOP_SH="$PULSAR_HOME/bin/pulsar-daemon stop standalone"
PULSAR_CONSOLE_DIR=$PULSAR_LOG_DIR
PULSAR_CONSOLE_LOG=${PULSAR_CONSOLE_DIR}/pulsar-standalone-$HOSTNAME.log
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
prog=pulsar
DESC="pulsar daemon"
RETVAL=0
STARTUP_WAIT=30
SHUTDOWN_WAIT=30
mkdir -p $(dirname $PULSAR_PIDFILE)
# Source function library.
. /lib/lsb/init-functions
start() {
echo -n $"Starting $prog: "
# Run daemon
cd $PULSAR_HOME
$PULSAR_START_SH
count=0
launched=false
sleep 1
until [ $count -gt $STARTUP_WAIT ]
do
grep 'messaging service is ready, bootstrap service port =' $PULSAR_CONSOLE_LOG > /dev/null
if [ $? -eq 0 ] ; then
launched=true
break
fi
sleep 1
let count=$count+1;
echo -ne "wait ${count}s\r"
done
if [ $launched = 'true' ] ; then
log_success_msg "pulsar start success"
else
log_failure_msg "pulsar start failed"
fi
echo
return 0
}
stop() {
echo -n $"Stopping $prog: "
$PULSAR_STOP_SH
log_success_msg "pulsar stop success"
echo
}
reload() {
stop
start
}
restart() {
stop
start
}
status() {
if ! ps -p $PULSAR_PIDFILE > /dev/null ; then
echo "$prog is not running"
return 1;
fi
echo "$prog is running"
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|status}"
exit 1
esac
exit $?