Last active
August 29, 2015 13:56
-
-
Save llvtt/9260081 to your computer and use it in GitHub Desktop.
mongo-connector init script (tested on CentOS 6.5)
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/bash | |
| # | |
| # mongo-connector Start Mongo Connector | |
| # | |
| # chkconfig: 345 90 25 | |
| # description: Mongo Connector replicates data from MongoDB to external | |
| # database systems. | |
| ### BEGIN INIT INFO | |
| # Provides: mongo-connector | |
| # Default-Start: 3 4 5 | |
| # Default-Stop: 0 1 6 | |
| # Short-Description: Start up Mongo Connector | |
| # Description: Mongo Connector replicates data from MongoDB to external | |
| # database systems. | |
| ### END INIT INFO | |
| # path to wrapper script | |
| wrapper=/opt/mongo-connector/mongo-connector.start | |
| # source function library | |
| . /etc/rc.d/init.d/functions | |
| RETVAL=0 | |
| lockfile=/var/lock/subsys/mongo-connector | |
| pidfile=/var/run/mongo-connector.pid | |
| start() | |
| { | |
| [ -x $mc ] || exit 5 | |
| action "starting mongo-connector: " daemon --pidfile $pidfile $wrapper | |
| RETVAL=$? | |
| if [ $RETVAL -eq 0 ]; then | |
| echo "done." | |
| else | |
| echo "failed. Please check exit code and logs for more information" | |
| fi | |
| return $RETVAL | |
| } | |
| stop() | |
| { | |
| action "stopping mongo-connector: " killproc -p $pidfile | |
| RETVAL=$? | |
| if [ $RETVAL -eq 0 ]; then | |
| echo "done." | |
| rm -f $lockfile | |
| else | |
| echo "failed. Please check exit code and logs for more information" | |
| fi | |
| return $RETVAL | |
| } | |
| restart() { | |
| $0 stop | |
| $0 start | |
| } | |
| case "$1" in | |
| start) | |
| start | |
| ;; | |
| stop) | |
| stop | |
| ;; | |
| restart) | |
| restart | |
| ;; | |
| status) | |
| status -p $pidfile mongo-connector | |
| ;; | |
| *) | |
| echo $"Usage: $0 {start|stop|restart|status}" | |
| RETVAL=2 | |
| esac | |
| exit $RETVAL |
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
| # path to mongo-connector | |
| mc="/usr/bin/mongo-connector" | |
| # options to pass to mongo-connector | |
| mc_options="-m localhost:27017 -t http://localhost:8983/solr -d /opt/mongo-connector/doc_managers/solr_doc_manager.py -o /opt/mongo-connector/oplog.txt" | |
| # log path | |
| mc_log="/var/log/mongo-connector.log" | |
| pidfile=/var/run/mongo-connector.pid | |
| nohup $mc $mc_options > $mc_log 2>&1 & | |
| echo $! > $pidfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment