GIT: [PATCH 1/2] Whitespace cleanup
Nothing crazy, just replacing <tab> with <spaces> and consistent indentation.
GIT: [PATCH 2/2] Add THIN_LOCKFILE for proper service shutdown
This change introduces a LOCKFILE variable for proper shutdown handling by /etc/init.d/killall. The presence of the LOCKFILE also helps cleanup 'service aeolus-conductor status' output in the event that thin has failed.
I also submitted a pull request for this changeset - https://github.com/aeolusproject/conductor/pull/1
Thanks, James
--- conf/aeolus-conductor | 72 ++++++++++++++++++++++++------------------------ 1 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/conf/aeolus-conductor b/conf/aeolus-conductor index 0a15fc1..52ae9dd 100755 --- a/conf/aeolus-conductor +++ b/conf/aeolus-conductor @@ -32,36 +32,36 @@ STARTTIMEOUT=60 start() { echo -n "Starting aeolus-conductor: " if [ -f "$THIN_PID" ] && checkpid `cat $THIN_PID` ; then - echo_failure - echo - echo "Thin is already running" - exit 1 + echo_failure + echo + echo "Thin is already running" + exit 1 fi
$THIN_PROG start -c "$CONDUCTOR_DIR" -l "$THIN_LOG" -P "$THIN_PID" \ - -a $ADDR -e $RAILS_ENV --user $CONDUCTOR_USER -g $CONDUCTOR_GROUP -d --prefix=$PREFIX \ - --rackup "$CONDUCTOR_DIR/config.ru" + -a $ADDR -e $RAILS_ENV --user $CONDUCTOR_USER -g $CONDUCTOR_GROUP -d --prefix=$PREFIX \ + --rackup "$CONDUCTOR_DIR/config.ru" RETVAL=$? if [ $RETVAL -eq 0 ] ; then - # wait until we can contact the server - # this bit is based on what the mysql init script does - TIMEOUT="$STARTTIMEOUT" - while [ $TIMEOUT -gt 0 ]; do - /usr/bin/curl --silent http://$ADDR:3000$PREFIX >& /dev/null - RETVAL=$? - if [ $RETVAL -eq 0 ] ; then - echo_success - echo - exit 0 - fi - sleep 1 - let TIMEOUT=${TIMEOUT}-1 - done + # wait until we can contact the server + # this bit is based on what the mysql init script does + TIMEOUT="$STARTTIMEOUT" + while [ $TIMEOUT -gt 0 ]; do + /usr/bin/curl --silent http://$ADDR:3000$PREFIX >& /dev/null + RETVAL=$? + if [ $RETVAL -eq 0 ] ; then + echo_success + echo + exit 0 + fi + sleep 1 + let TIMEOUT=${TIMEOUT}-1 + done fi
- echo_failure - echo - exit 1 + echo_failure + echo + exit 1 }
stop() { @@ -71,28 +71,28 @@ stop() {
case "$1" in start) - start - ;; + start + ;; stop) - stop - ;; + stop + ;; restart) - stop - start - ;; + stop + start + ;; reload) ;; force-reload) restart ;; status) - status -p $THIN_PID - RETVAL=$? - ;; + status -p $THIN_PID + RETVAL=$? + ;; *) - echo "Usage: aeolus-conductor {start|stop|restart|reload|force-reload|status}" - exit 1 - ;; + echo "Usage: aeolus-conductor {start|stop|restart|reload|force-reload|status}" + exit 1 + ;; esac
exit $RETVAL
--- conf/aeolus-conductor | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/conf/aeolus-conductor b/conf/aeolus-conductor index 52ae9dd..ccc4235 100755 --- a/conf/aeolus-conductor +++ b/conf/aeolus-conductor @@ -19,6 +19,7 @@ CONDUCTOR_GROUP="${CONDUCTOR_GROUP:-aeolus}" THIN_PROG="${THIN_PROG:-thin}" THIN_PID="${THIN_PID:-/var/run/aeolus-conductor/thin.pid}" THIN_LOG="${THIN_LOG:-/var/log/aeolus-conductor/thin.log}" +THIN_LOCKFILE="${THIN_LOCKFILE:-/var/lock/subsys/aeolus-conductor}" PREFIX="${PREFIX:-/conductor}" ADDR="${ADDR:-127.0.0.1}"
@@ -30,11 +31,11 @@ STARTTIMEOUT=60 . /etc/init.d/functions
start() { - echo -n "Starting aeolus-conductor: " + echo -n "Starting ${THIN_PROG}: " if [ -f "$THIN_PID" ] && checkpid `cat $THIN_PID` ; then echo_failure echo - echo "Thin is already running" + echo "${THIN_PROG} is already running" exit 1 fi
@@ -50,6 +51,7 @@ start() { /usr/bin/curl --silent http://$ADDR:3000$PREFIX >& /dev/null RETVAL=$? if [ $RETVAL -eq 0 ] ; then + touch ${THIN_LOCKFILE} echo_success echo exit 0 @@ -65,8 +67,11 @@ start() { }
stop() { - echo -n "Shutting down aeolus-conductor: " - killproc -p $THIN_PID thin + echo -n "Shutting down ${THIN_PROG}: " + killproc -p $THIN_PID ${THIN_PROG} + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f ${THIN_LOCKFILE} ${THIN_PID} }
case "$1" in @@ -86,7 +91,7 @@ case "$1" in restart ;; status) - status -p $THIN_PID + status -p ${THIN_PID} ${THIN_PROG} RETVAL=$? ;; *)
https://bugzilla.redhat.com/show_bug.cgi?id=786865
In the event that the thin process has died for some reason, service status will report:
# service aeolus-conductor status is stopped
The use of a LOCKFILE corrects the output, in addition to improved handling during system shutdown (/etc/init.d/killall):
# service aeolus-conductor status aeolus-conductor dead but subsys locked
--- conf/aeolus-conductor | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/conf/aeolus-conductor b/conf/aeolus-conductor index 52ae9dd..ccc4235 100755 --- a/conf/aeolus-conductor +++ b/conf/aeolus-conductor @@ -19,6 +19,7 @@ CONDUCTOR_GROUP="${CONDUCTOR_GROUP:-aeolus}" THIN_PROG="${THIN_PROG:-thin}" THIN_PID="${THIN_PID:-/var/run/aeolus-conductor/thin.pid}" THIN_LOG="${THIN_LOG:-/var/log/aeolus-conductor/thin.log}" +THIN_LOCKFILE="${THIN_LOCKFILE:-/var/lock/subsys/aeolus-conductor}" PREFIX="${PREFIX:-/conductor}" ADDR="${ADDR:-127.0.0.1}"
@@ -30,11 +31,11 @@ STARTTIMEOUT=60 . /etc/init.d/functions
start() { - echo -n "Starting aeolus-conductor: " + echo -n "Starting ${THIN_PROG}: " if [ -f "$THIN_PID" ] && checkpid `cat $THIN_PID` ; then echo_failure echo - echo "Thin is already running" + echo "${THIN_PROG} is already running" exit 1 fi
@@ -50,6 +51,7 @@ start() { /usr/bin/curl --silent http://$ADDR:3000$PREFIX >& /dev/null RETVAL=$? if [ $RETVAL -eq 0 ] ; then + touch ${THIN_LOCKFILE} echo_success echo exit 0 @@ -65,8 +67,11 @@ start() { }
stop() { - echo -n "Shutting down aeolus-conductor: " - killproc -p $THIN_PID thin + echo -n "Shutting down ${THIN_PROG}: " + killproc -p $THIN_PID ${THIN_PROG} + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f ${THIN_LOCKFILE} ${THIN_PID} }
case "$1" in @@ -86,7 +91,7 @@ case "$1" in restart ;; status) - status -p $THIN_PID + status -p ${THIN_PID} ${THIN_PROG} RETVAL=$? ;; *)
On 03/02/12 10:23 -0500, James Laska wrote:
GIT: [PATCH 1/2] Whitespace cleanup
Nothing crazy, just replacing <tab> with <spaces> and consistent indentation.
GIT: [PATCH 2/2] Add THIN_LOCKFILE for proper service shutdown
This change introduces a LOCKFILE variable for proper shutdown handling by /etc/init.d/killall. The presence of the LOCKFILE also helps cleanup 'service aeolus-conductor status' output in the event that thin has failed.
I also submitted a pull request for this changeset - https://github.com/aeolusproject/conductor/pull/1
Thanks, James
ACK to the set (with revised 2/2). These are pushed to staging and should land on master sometime early next week.
-j
aeolus-devel@lists.fedorahosted.org