-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongod
executable file
·58 lines (53 loc) · 1.24 KB
/
mongod
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
#!/bin/bash
### BEGIN INIT INFO
# Provides: mongod
# Required-Start: $local_fs $network
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mongod service
# Description: MongoDB SysV service, useful when Systemd is not available
### END INIT INFO
process_spec="--user mongodb --pidfile /run/mongod-sysv.pid"
case "$1" in
status)
echo "Checking status of mongod..."
start-stop-daemon --status $process_spec
result=$?
if [ "$result" = 0 ]; then
echo "mongod is running."
else
echo "mongod is not running ($result)."
fi
exit "$result"
;;
start)
echo "Starting mongod..."
# Did not work: --notify-await
start-stop-daemon --start --oknodo $process_spec \
--chuid mongodb:mongodb --make-pidfile --background \
--startas /usr/bin/mongod \
-- --config /etc/mongod.conf
echo -n "Waiting for localhost:27017..."
while ! nc -z localhost 27017; do
echo -n "."
sleep 0.1
done
echo " OK."
;;
stop)
echo "Stopping mongod..."
start-stop-daemon --stop --oknodo $process_spec \
--remove-pidfile --retry 5
echo "OK."
;;
restart)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {status|start|stop|restart}"
exit 1
;;
esac
exit 0