From 536b8c1d2cf9d2523dc60f74190ef566a8c3fc4b Mon Sep 17 00:00:00 2001 From: Tony Breeds Date: Mon, 9 Nov 2015 10:05:37 +1100 Subject: [PATCH] Allow screen without logging to disk In some niche setups it is desirable to run OpenStack services under screen, but undesirable to automatically keep a persistent log from each service. Add a new variable SCREEN_IS_LOGGING that controls if screen logs each window to disk automatically. 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 Change-Id: I2a3abf15dea95ae99ddbdfe1309382df601b7d93 --- functions-common | 14 +++++++++----- stackrc | 10 ++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/functions-common b/functions-common index ca0543da7d..ba3c79126d 100644 --- a/functions-common +++ b/functions-common @@ -1366,7 +1366,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. @@ -1386,8 +1386,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 @@ -1426,7 +1430,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} @@ -1446,7 +1450,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 diff --git a/stackrc b/stackrc index 3033b27580..76a5756dde 100644 --- a/stackrc +++ b/stackrc @@ -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