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:
		
							
								
								
									
										18
									
								
								rejoin-stack.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										18
									
								
								rejoin-stack.sh
									
									
									
									
									
										Executable 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
 | 
				
			||||||
							
								
								
									
										23
									
								
								stack.sh
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								stack.sh
									
									
									
									
									
								
							@@ -1249,10 +1249,31 @@ fi
 | 
				
			|||||||
# so send the start command by forcing text into the window.
 | 
					# so send the start command by forcing text into the window.
 | 
				
			||||||
# Only run the services specified in ``ENABLED_SERVICES``
 | 
					# 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 {
 | 
					function screen_it {
 | 
				
			||||||
    NL=`echo -ne '\015'`
 | 
					    NL=`echo -ne '\015'`
 | 
				
			||||||
    if is_service_enabled $1; then
 | 
					    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
 | 
					        screen -S stack -X screen -t $1
 | 
				
			||||||
        # sleep to allow bash to be ready to be send the command - we are
 | 
					        # 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
 | 
					        # creating a new window in screen and then sends characters, so if
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user