Skip to content

Commit 58e2134

Browse files
committed
Add option to make screen starting more robust.
We have seen a number of failures in ci where a host is overloaded and the 1.5 second sleep before stuffing data into screen is not long enough. This means the service doesn't start and tests fail. This change adds a config option to allow us to turn off the developer friendly option to stuff text into the screen. When SCREEN_DEV is set to False it will use a simple exec in screen instead of stuff. This should be far more reliable because we don't have to wait for bash to start. Change-Id: I7f1b5dbf5329b23507cb767d54a2795be0d73e01
1 parent 098b272 commit 58e2134

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

functions

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -738,26 +738,31 @@ function restart_service() {
738738
# Helper to launch a service in a named screen
739739
# screen_it service "command-line"
740740
function screen_it {
741-
NL=`echo -ne '\015'`
742741
SCREEN_NAME=${SCREEN_NAME:-stack}
743742
SERVICE_DIR=${SERVICE_DIR:-${DEST}/status}
743+
SCREEN_DEV=`trueorfalse True $SCREEN_DEV`
744744

745745
if is_service_enabled $1; then
746746
# Append the service to the screen rc file
747747
screen_rc "$1" "$2"
748748

749749
screen -S $SCREEN_NAME -X screen -t $1
750-
# sleep to allow bash to be ready to be send the command - we are
751-
# creating a new window in screen and then sends characters, so if
752-
# bash isn't running by the time we send the command, nothing happens
753-
sleep 1.5
754-
755-
if [[ -n ${SCREEN_LOGDIR} ]]; then
756-
screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
757-
screen -S $SCREEN_NAME -p $1 -X log on
758-
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
750+
if [[ "$SCREEN_DEV" = "True" ]]; then
751+
# sleep to allow bash to be ready to be send the command - we are
752+
# creating a new window in screen and then sends characters, so if
753+
# bash isn't running by the time we send the command, nothing happens
754+
sleep 1.5
755+
756+
if [[ -n ${SCREEN_LOGDIR} ]]; then
757+
screen -S $SCREEN_NAME -p $1 -X logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log
758+
screen -S $SCREEN_NAME -p $1 -X log on
759+
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
760+
fi
761+
NL=`echo -ne '\015'`
762+
screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
763+
else
764+
screen -S $SCREEN_NAME -p $1 -X exec /bin/bash -c "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\""
759765
fi
760-
screen -S $SCREEN_NAME -p $1 -X stuff "$2 || touch \"$SERVICE_DIR/$SCREEN_NAME/$1.failure\"$NL"
761766
fi
762767
}
763768

stackrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ ENABLED_SERVICES=g-api,g-reg,key,n-api,n-crt,n-obj,n-cpu,n-net,n-cond,cinder,c-s
2929
# Set the default Nova APIs to enable
3030
NOVA_ENABLED_APIS=ec2,osapi_compute,metadata
3131

32+
# Whether to use 'dev mode' for screen windows. Dev mode works by
33+
# stuffing text into the screen windows so that a developer can use
34+
# ctrl-c, up-arrow, enter to restart the service. Starting services
35+
# this way is slightly unreliable, and a bit slower, so this can
36+
# be disabled for automated testing by setting this value to false.
37+
SCREEN_DEV=True
38+
3239
# Repositories
3340
# ------------
3441

0 commit comments

Comments
 (0)