From: <tho...@us...> - 2013-11-22 21:03:09
|
Revision: 7585 http://bigdata.svn.sourceforge.net/bigdata/?rev=7585&view=rev Author: thompsonbry Date: 2013-11-22 21:03:03 +0000 (Fri, 22 Nov 2013) Log Message: ----------- I have added an init.d style script: bigdataHA (start|stop|status|restart) This script relies on a bigdataHAEnv that MUST define the following variables to specify the location of the installed scripts. These variables SHOULD use absolute path names. binDir pidFile This script could be used by an rpm or other installer to install the HA replication cluster as an init.d style service on a linux platform. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/build.xml Added Paths: ----------- branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHA branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHAEnv Modified: branches/BIGDATA_RELEASE_1_3_0/build.xml =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/build.xml 2013-11-22 19:17:14 UTC (rev 7584) +++ branches/BIGDATA_RELEASE_1_3_0/build.xml 2013-11-22 21:03:03 UTC (rev 7585) @@ -1051,6 +1051,13 @@ todir="${dist.bin}" /> <chmod file="${dist.bin}/startHAServices" perm="755" /> + <copy file="${src.resources}/bin/bigdataHA" + todir="${dist.bin}" /> + <chmod file="${dist.bin}/bigdataHA" perm="755" /> + + <copy file="${src.resources}/bin/bigdataHAEnv" + todir="${dist.bin}" /> + <copy file="${src.resources}/bin/config/browser.config" todir="${dist.bin.config}" /> <copy file="${src.resources}/bin/config/reggie.config" Added: branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHA =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHA (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHA 2013-11-22 21:03:03 UTC (rev 7585) @@ -0,0 +1,131 @@ +#!/bin/bash + +# init.d style script for bigdata HA services. The script can be used +# to 'start' or 'stop' services. +# +# Environment: +# +# binDir - The directory containing the installed scripts. +# pidFile - The pid is written on this file. +# +# Misc. +# +# See http://tldp.org/LDP/abs/html/index.html +# +# Note: Blank lines are significant in shell scripts. +# +# Note: Children must do "exit 0" to indicate success. +# +# Note: Convert DOS cr-lf to unix style in emacs: C-x RET f then unix + +# Source function library (just used for 'action'). If you don't have this +# it SHOULD automatically use the inline definition for "action()". +if [ -f "/etc/init.d/functions" ]; then + . /etc/init.d/functions +else +# Run some action. Log its output. No fancy colors. First argument is the +# label for the log file. Remaining arguments are the command to execute +# and its arguments, if any. + action() { + local STRING rc + STRING=$1 + echo -n "$STRING " + shift + "$@" && echo -n "[OK]" || echo -n "[FAILED]" + rc=$? + echo + return $rc + } +fi + +# Where the scripts live. +cd `dirname $0` + +## +# Highly Recommended OS Tuning. +## + +# Do not swap out applications while there is free memory. +#/sbin/sysctl -w vm.swappiness=0 + +# Setup the environment. +source ./bigdataHAEnv + +if [ -z "$binDir" ]; then + echo $"$0 : environment not setup: binDir is undefined." + exit 1; +fi +if [ -z "$pidFile" ]; then + echo $"$0 : environment not setup: pidFile is undefined" + exit 1; +fi + +# +# See how we were called. +# +case "$1" in + start) +# +# Start the ServiceStarter and child services if not running. +# + if [ -f "$pidFile" ]; then + read pid < "$pidFile" + pidno=$( ps ax | grep $pid | awk '{ print $1 }' | grep $pid ) + if [ -z "$pidno" ]; then +# The process has died so remove the old pid file. + echo $"`date` : `hostname` : $pid died?" + rm -f "$pidFile" + fi + fi + if [ ! -f "$pidFile" ]; then + action $"`date` : `hostname` : bringing up services: " $binDir/startHAServices + else + echo $"`date` : `hostname` : running as $pid" + fi + ;; + stop) +# +# Stop the ServiceStarter and all child services. +# + if [ -f "$pidFile" ]; then + read pid < "$pidFile" + pidno=$( ps ax | grep $pid | awk '{ print $1 }' | grep $pid ) + if [ -z "$pidno" ]; then +# The process has died so remove the old pid file. + echo $"`date` : `hostname` : $pid died?" + rm -f "$pidFile" + else + action $"`date` : `hostname` : bringing down services: " kill $pid + rm -f "$pidFile" + fi + fi + ;; + status) +# +# Report status for the ServicesManager (up or down). +# + if [ -f "$pidFile" ]; then + read pid < "$pidFile" + pidno=$( ps ax | grep $pid | awk '{ print $1 }' | grep $pid ) + if [ -z "$pidno" ]; then + echo $"`date` : `hostname` : process died? pid=$pid." + else + echo $"`date` : `hostname` : running as $pid." + fi + else + echo $"`date` : `hostname` : not running." + fi + ;; + restart) + $0 stop + $0 start + ;; + *) +# +# Usage +# + echo $"Usage: $0 {start|stop|status|restart}" + exit 1 +esac + +exit 0 Property changes on: branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHA ___________________________________________________________________ Added: svn:executable + * Added: branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHAEnv =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHAEnv (rev 0) +++ branches/BIGDATA_RELEASE_1_3_0/src/resources/bin/bigdataHAEnv 2013-11-22 21:03:03 UTC (rev 7585) @@ -0,0 +1,11 @@ +# Environment for bigdata HA services. +# +# binDir - The directory containing the installed scripts. +# pidFile - The pid is written on this file. +# +# Note: You MUST provide the location of the executable scripts and the +# pid file that is written by $binDir/startHAServices. These SHOULD be +# absolute path names. + +#binDir= +#pidFile= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |