-
Notifications
You must be signed in to change notification settings - Fork 27
/
control
executable file
·89 lines (81 loc) · 2.09 KB
/
control
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
#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
function is_running() {
if [ ! -z "$(ps -ef | grep 'mongod --nounixsocket' | grep -v grep)" ]; then
return 0
else
return 1
fi
}
function start() {
if is_running; then
client_result 'MongoDB is already running.'
else
client_message 'Starting MongoDB...'
nohup ${OPENSHIFT_DATA_DIR}.mongodb/bin/mongod \
--nounixsocket \
--storageEngine wiredTiger \
--wiredTigerEngineConfigString="cache_size=256M" \
--dbpath ${OPENSHIFT_DATA_DIR}.mongodb/data \
--bind_ip $OPENSHIFT_MONGODB_IP \
--quiet \
--logRotate reopen \
--logappend \
|& /usr/bin/logshifter -tag mongodb &
i=0
while ! is_running && [ $i -lt 60 ]; do
sleep 1
i=$(($i + 1))
done
if is_running; then
client_result 'MongoDB started.'
else
client_result 'Warning! Could not start MongoDB!'
exit 1
fi
fi
}
function stop() {
if ! is_running; then
client_result 'MongoDB is already stopped.'
else
client_message 'Stopping MongoDB...'
kill "$(ps -ef | grep 'mongod --nounixsocket' | grep -v grep | awk '{ print $2 }')" > /dev/null 2>&1
i=0
while is_running && [ $i -lt 60 ]; do
sleep 1
i=$(($i + 1))
done
if is_running; then
client_result 'Warning! Could not stop MongoDB!'
exit 1
else
client_result 'MongoDB stopped.'
fi
fi
}
function restart() {
stop
start
}
function status() {
if is_running; then
client_result 'MongoDB appears to be running.'
else
client_result 'MongoDB appears to be stopped.'
fi
}
function tidy() {
shopt -s dotglob
client_message "Emptying logs in ${OPENSHIFT_LOG_DIR}..."
rm -rf ${OPENSHIFT_LOG_DIR}/*.log*
client_message 'Done.'
}
case ${1} in
start) start ;;
stop) stop ;;
restart) restart ;;
status) status ;;
tidy) tidy ;;
*) exit 0
esac