[Note] MacOSMongoDB Startup Script

Source: Internet
Author: User
#! Binbaslif [-z $1]; thenechoUsage: $0 [start | stop | restart] exit1fiSourcethecommonsetupfunctionsforstartupscriptstest-retcrc.common | exit1.etcrc. commonsetupsomedefaultsdbpathusrlocal1_dbdbdblo

#! /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 ults

DBPATH = '/usr/local/mongodb/db'
LOGPATH = '/usr/local/mongodb/log/mongod. Log'
Export d_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 PIDif [ -e $pidfile ]; then    pid=`cat $pidfile`fi# If we don't have a PID, check for itif [ "$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 itif [ "$pid" != "" ]; then    kill -15 $pidfi

}

RestartService (){
StopService
Sleep 3
StartService
}

RunService $1

Original article address: [Note] Mac OS MongoDB STARTUP script. Thank you for sharing it with me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.