当前位置:首页 > PHP教程 > PHP总结归纳

[Note]MacOSMongoDB启动脚本

#!/bin/bash if [ -z $1 ] ; then echo "usage: $0 [start|stop|restart] " exit 1 fi source the common setup functions for startup scripts test -r /etc/rc.common || exit 1 . /etc/rc.common set up some defaults dbpath='/usr/local/mongodb/db' lo

#!/bin/bash

if [ -z $1 ] ; then
echo "usage: $0 [start|stop|restart] "
exit 1
fi

source the common setup functions for startup scripts

test -r /etc/rc.common || exit 1
. /etc/rc.common

set up some defaults

dbpath='/usr/local/mongodb/db'
logpath='/usr/local/mongodb/log/mongod.log'
mongod_port=27017

startservice(){
/usr/local/mongodb/bin/mongod run --dbpath=$dbpath --logpath=$logpath --port $mongod_port > /dev/null 2>&1 &
}

stopservice() {
pidfile=$dbpath/mongod.lock

# if the lockfile exists, it contains the pid
if [ -e $pidfile ]; then
    pid=`cat $pidfile`
fi
# if we don't have a pid, check for it
if [ "$pid" == "" ]; then
    pid=`/usr/sbin/lsof -i tcp:$mongod_port | tail -1 | awk '{print $2}'`
fi
# if we've found a pid, let's kill it
if [ "$pid" != "" ]; then
    kill -15 $pid
fi

}

restartservice() {
stopservice
sleep 3
startservice
}

runservice $1


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!