Created
          August 15, 2015 05:41 
        
      - 
      
- 
        Save bertrandmartel/a3865fa441248f23d51e to your computer and use it in GitHub Desktop. 
    mongod service init.d launcher script 
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/bin/sh | |
| #title :mongod | |
| #author :Bertrand Martel | |
| #date :15/08/2015 | |
| #description :start/stop/restart mongod | |
| ######################################### | |
| ### install : cp mongod /etc/init.d/ | |
| # update-rc.d mongod defaults | |
| ### uninstall : update-rc.d -f mongodb remove | |
| PATH_TO_MONGO=/usr/bin/mongod | |
| #file containing all mongodb pid | |
| PID_FILE=/tmp/mongodb.pid | |
| case "$1" in | |
| start) | |
| echo "Starting mongodb service..." | |
| COMMAND_TO_RUN=`start-stop-daemon -S -b -m -p $PID_FILE -x $PATH_TO_MONGO& :` | |
| setsid sh -c $COMMAND_TO_RUN> /dev/null 2>&1 < /dev/null | |
| echo -e "\E[31;33m[ OK ]\E[0m" | |
| ;; | |
| stop) | |
| echo "Stopping mongodb service..." | |
| start-stop-daemon -K -q -p $PID_FILE | |
| echo -e "\E[31;33m[ OK ]\E[0m" | |
| ;; | |
| restart|reload) | |
| "$0" stop | |
| "$0" start | |
| ;; | |
| *) | |
| echo $"Usage: $0 {start|stop|restart}" | |
| exit 1 | |
| esac | |
| exit $? | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment