-
Notifications
You must be signed in to change notification settings - Fork 12
/
esmeralda.sh
executable file
·62 lines (52 loc) · 1.12 KB
/
esmeralda.sh
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
#!/bin/bash
#
# /etc/rc.d/init.d/esmeralda
#
# chuanyun.io esmeralda
#
# chkconfig: 2345 20 80 Read
# description: chuanyun.io esmeralda
# processname: esmeralda
# Source function library.
. /etc/rc.d/init.d/functions
PROGHOME=${PWD}
PROG=${PROGHOME}/esmeralda
PROGNAME=${PROG##*/}
LOCKFILE=${PROGHOME}/$PROGNAME.lock
PIDFILE=${PROGHOME}/$PROGNAME.pid
CONFIG_FILE_PATH=${PROGHOME}/esmeralda.toml
start() {
echo -n $"Starting $PROGNAME: "
daemon --check=$PROGNAME "${PROG} -config=$CONFIG_FILE_PATH -pidfile=$PIDFILE -pprof=true -pprof.port=10201 &"
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${LOCKFILE}
return $RETVAL
}
stop() {
echo -n $"Stopping ${PROGNAME}: "
killproc -p ${PIDFILE} ${PROGNAME}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
}
rh_status() {
status -p ${PIDFILE} -b ${PROG} ${PROG}
}
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo $"Usage: ${PROGNAME} {start|stop|restart}"
exit 2
;;
esac