Restart openstack services after running stack.sh

* Added screen_rc function in stack.sh to save started services to stack-screenrc file
* Added rejoin-stack.sh to rejoin the current screen session or start a new session

Change-Id: I381a7832bc8a107bfbd51c5ecfbd2e9134cf0a0a
blueprint: restart-services
This commit is contained in:
Derrick J. Wippler 2012-02-21 09:53:53 -06:00
parent 1e98bdc5b4
commit aaa0dbb2e7
2 changed files with 40 additions and 1 deletions

18
rejoin-stack.sh Executable file
View File

@ -0,0 +1,18 @@
#! /usr/bin/env bash
# This script rejoins an existing screen, or re-creates a
# screen session from a previous run of stack.sh.
TOP_DIR=`dirname $0`
# if screenrc exists, run screen
if [[ -e $TOP_DIR/stack-screenrc ]]; then
if screen -ls | egrep -q "[0-9].stack"; then
echo "Attaching to already started screen session.."
exec screen -r stack
fi
exec screen -c $TOP_DIR/stack-screenrc
fi
echo "Couldn't find $TOP_DIR/stack-screenrc file; have you run stack.sh yet?"
exit 1

View File

@ -1249,10 +1249,31 @@ fi
# so send the start command by forcing text into the window.
# Only run the services specified in ``ENABLED_SERVICES``
# our screen helper to launch a service in a hidden named screen
# Our screenrc file builder
function screen_rc {
SCREENRC=$TOP_DIR/stack-screenrc
if [[ ! -e $SCREENRC ]]; then
# Name the screen session
echo "sessionname stack" > $SCREENRC
# Set a reasonable statusbar
echo 'hardstatus alwayslastline "%-Lw%{= BW}%50>%n%f* %t%{-}%+Lw%< %= %H"' >> $SCREENRC
echo "screen -t stack bash" >> $SCREENRC
fi
# If this service doesn't already exist in the screenrc file
if ! grep $1 $SCREENRC 2>&1 > /dev/null; then
NL=`echo -ne '\015'`
echo "screen -t $1 bash" >> $SCREENRC
echo "stuff \"$2$NL\"" >> $SCREENRC
fi
}
# Our screen helper to launch a service in a hidden named screen
function screen_it {
NL=`echo -ne '\015'`
if is_service_enabled $1; then
# Append the service to the screen rc file
screen_rc "$1" "$2"
screen -S stack -X screen -t $1
# sleep to allow bash to be ready to be send the command - we are
# creating a new window in screen and then sends characters, so if