Permalink
Browse files

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
  • Loading branch information...
1 parent 1e98bdc commit aaa0dbb2e7aab9a1b8ebeb2cc6c3d373a0f81d5c @thrawn01 thrawn01 committed Feb 21, 2012
Showing with 40 additions and 1 deletion.
  1. +18 −0 rejoin-stack.sh
  2. +22 −1 stack.sh
View
@@ -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
@@ -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

0 comments on commit aaa0dbb

Please sign in to comment.