Update README.md
This commit is contained in:
parent
72962672b9
commit
e236815388
71
README.md
71
README.md
|
@ -593,34 +593,89 @@ start)
|
|||
fi
|
||||
done
|
||||
if [ $COUNTER == 0 ]; then
|
||||
echo "starting mongo."
|
||||
sudo mongod --config /etc/mongod.conf &
|
||||
exit 0
|
||||
else
|
||||
echo "mongo is already running."
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo "stoping mongo."
|
||||
if [ -f "/var/lib/mongodb/mongod.lock" ]; then
|
||||
sudo kill -s TERM `cat /var/lib/mongodb/mongod.lock`
|
||||
sudo rm -f /var/lib/mongodb/mongod.lock
|
||||
else
|
||||
pid=`ps aux | grep mongod | grep -v 'service' | grep -v 'grep' | grep -v '/etc/init.d' | awk '{print $2}'`;
|
||||
for i in $pid
|
||||
do
|
||||
kill -s TERM $i
|
||||
done
|
||||
fi
|
||||
sudo rm -f /var/lib/mongodb/mongod.lock
|
||||
;;
|
||||
restart|reload)
|
||||
echo "stoping mongo."
|
||||
if [ -f "/var/lib/mongodb/mongod.lock" ]; then
|
||||
sudo kill -s TERM `cat /var/lib/mongodb/mongod.lock`
|
||||
fi
|
||||
sudo rm -f /var/lib/mongodb/mongod.lock
|
||||
sudo kill -s TERM `cat /var/lib/mongodb/mongod.lock`
|
||||
sudo rm -f /var/lib/mongodb/mongod.lock
|
||||
else
|
||||
pid=`ps aux | grep mongod | grep -v 'service' | grep -v 'grep' | grep -v '/etc/init.d' | awk '{print $2}'`;
|
||||
for i in $pid
|
||||
do
|
||||
kill -s TERM $i
|
||||
done
|
||||
fi
|
||||
sudo mongod --config /etc/mongod.conf &
|
||||
exit 0
|
||||
;;
|
||||
status)
|
||||
if [ -f "/var/lib/mongodb/mongod.lock" ]; then
|
||||
if [ -f "/proc/$(cat /var/lib/mongodb/mongod.lock)/status" ]; then
|
||||
pid=`cat /var/lib/mongodb/mongod.lock`
|
||||
COUNTER=0
|
||||
ERRORPID=0
|
||||
for i in $pid
|
||||
do
|
||||
if [ -f "/proc/$i/status" ]; then
|
||||
COUNTER=$((COUNTER+1))
|
||||
else
|
||||
ERRORPID=1
|
||||
fi
|
||||
done
|
||||
if [ $ERRORPID == 0 ] && [ $COUNTER != 0 ]; then
|
||||
echo "mongo is already running"
|
||||
else
|
||||
echo "mongo is not running"
|
||||
else
|
||||
COUNTER=0
|
||||
pid=`ps aux | grep mongod | grep -v 'service' | grep -v 'grep' | grep -v '/etc/init.d' | awk '{print $2}'`;
|
||||
cat /dev/null > /var/lib/mongodb/mongod.lock;
|
||||
for i in $pid
|
||||
do
|
||||
if [ -f "/proc/$i/status" ]; then
|
||||
echo "$i" >> /var/lib/mongodb/mongod.lock;
|
||||
COUNTER=$((COUNTER+1))
|
||||
fi
|
||||
done
|
||||
if [ $COUNTER == 0 ]; then
|
||||
echo "mongo is not running."
|
||||
else
|
||||
echo "mongo is already running."
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "mongo is not running"
|
||||
COUNTER=0
|
||||
pid=`ps aux | grep mongod | grep -v 'service' | grep -v 'grep' | grep -v '/etc/init.d' | awk '{print $2}'`;
|
||||
for i in $pid
|
||||
do
|
||||
if [ -f "/proc/$i/status" ]; then
|
||||
echo "$i" >> /var/lib/mongodb/mongod.lock;
|
||||
COUNTER=$((COUNTER+1))
|
||||
fi
|
||||
done
|
||||
if [ $COUNTER == 0 ]; then
|
||||
echo "mongo is not running."
|
||||
else
|
||||
echo "mongo is already running."
|
||||
fi
|
||||
fi
|
||||
esac
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue