Merge "Allow screen without logging to disk"

This commit is contained in:
Jenkins 2015-11-11 05:13:07 +00:00 committed by Gerrit Code Review
commit 7eaeefac80
2 changed files with 19 additions and 5 deletions

View File

@ -1370,7 +1370,7 @@ function run_process {
# Helper to launch a process in a named screen
# Uses globals ``CURRENT_LOG_TIME``, ```LOGDIR``, ``SCREEN_LOGDIR``, `SCREEN_NAME``,
# ``SERVICE_DIR``, ``USE_SCREEN``
# ``SERVICE_DIR``, ``USE_SCREEN``, ``SCREEN_IS_LOGGING``
# screen_process name "command-line" [group]
# Run a command in a shell in a screen window, if an optional group
# is provided, use sg to set the group of the command.
@ -1390,8 +1390,12 @@ function screen_process {
echo "SCREEN_LOGDIR: $SCREEN_LOGDIR"
echo "log: $real_logfile"
if [[ -n ${LOGDIR} ]]; then
screen -S $SCREEN_NAME -p $name -X logfile "$real_logfile"
screen -S $SCREEN_NAME -p $name -X log on
if [[ "$SCREEN_IS_LOGGING" == "True" ]]; then
screen -S $SCREEN_NAME -p $name -X logfile "$real_logfile"
screen -S $SCREEN_NAME -p $name -X log on
fi
# If logging isn't active then avoid a broken symlink
touch "$real_logfile"
ln -sf "$real_logfile" ${LOGDIR}/${name}.log
if [[ -n ${SCREEN_LOGDIR} ]]; then
# Drop the backward-compat symlink
@ -1430,7 +1434,7 @@ function screen_process {
}
# Screen rc file builder
# Uses globals ``SCREEN_NAME``, ``SCREENRC``
# Uses globals ``SCREEN_NAME``, ``SCREENRC``, ``SCREEN_IS_LOGGING``
# screen_rc service "command-line"
function screen_rc {
SCREEN_NAME=${SCREEN_NAME:-stack}
@ -1450,7 +1454,7 @@ function screen_rc {
echo "screen -t $1 bash" >> $SCREENRC
echo "stuff \"$2$NL\"" >> $SCREENRC
if [[ -n ${LOGDIR} ]]; then
if [[ -n ${LOGDIR} ]] && [[ "$SCREEN_IS_LOGGING" == "True" ]]; then
echo "logfile ${LOGDIR}/${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
echo "log on" >>$SCREENRC
fi

10
stackrc
View File

@ -103,6 +103,16 @@ HORIZON_APACHE_ROOT="/dashboard"
# be disabled for automated testing by setting this value to False.
USE_SCREEN=True
# When using screen, should we keep a log file on disk? You might
# want this False if you have a long-running setup where verbose logs
# can fill-up the host.
# XXX: Ideally screen itself would be configured to log but just not
# activate. This isn't possible with the screerc syntax. Temporary
# logging can still be used by a developer with:
# C-a : logfile foo
# C-a : log on
SCREEN_IS_LOGGING=$(trueorfalse True SCREEN_IS_LOGGING)
# Passwords generated by interactive devstack runs
if [[ -r $RC_DIR/.localrc.password ]]; then
source $RC_DIR/.localrc.password