-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathmangodb.init
61 lines (53 loc) · 1019 Bytes
/
mangodb.init
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
#!/bin/bash
#
# /etc/init.d/mangodb
#
# Startup script for MangoDB
#
# chkconfig: 2345 20 80
# description: Starts and stops MangoDB
. /etc/init.d/functions
mangoUser=mango
mangoBin=/opt/mangodb/bin/server.py
pythonBin=/usr/bin/python2.7
desc="MangoDB daemon"
outFile="/var/log/mangodb/mangodb.out"
if ! [ -f $mangoBin ]; then
echo "MangoDB binary not found."
exit 5
fi
if ! [ -f $pythonBin ]; then
echo "Python 2.7 binary not found."
exit 5
fi
start() {
echo "Starting $desc: "
su $mangoUser -c "nohup $pythonBin $mangoBin >>$outFile 2>&1 &"
RETVAL=$?
return $RETVAL
}
stop() {
echo "Shutting down $desc: "
pkill -f mangodb
}
restart() {
stop
start
}
status() {
pid=$(pgrep -f mangodb)
if [ -z $pid ]; then
echo "MangoDB is NOT running."
else
echo "MangoDB is running (pid is $pid)."
fi
}
case "$1" in
start) start;;
stop) stop;;
restart) restart;;
status) status;;
*) echo "Usage: $0 {start|stop|restart}"
RETVAL=2;;
esac
exit $RETVAL