Merge "Rename screen logfiles"

This commit is contained in:
Jenkins 2015-01-20 14:24:00 +00:00 committed by Gerrit Code Review
commit 256b8234a9
3 changed files with 17 additions and 18 deletions

View File

@ -1278,8 +1278,8 @@ function _run_process {
exec 6>&-
if [[ -n ${SCREEN_LOGDIR} ]]; then
exec 1>&${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${service}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${service}.log
exec 1>&${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${service}.log
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1
@ -1363,9 +1363,9 @@ function screen_process {
screen -S $SCREEN_NAME -X screen -t $name
if [[ -n ${SCREEN_LOGDIR} ]]; then
screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log
screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME}
screen -S $SCREEN_NAME -p $name -X log on
ln -sf ${SCREEN_LOGDIR}/screen-${name}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${name}.log
ln -sf ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${name}.log
fi
# sleep to allow bash to be ready to be send the command - we are
@ -1411,7 +1411,7 @@ function screen_rc {
echo "stuff \"$2$NL\"" >> $SCREENRC
if [[ -n ${SCREEN_LOGDIR} ]]; then
echo "logfile ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log" >>$SCREENRC
echo "logfile ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
echo "log on" >>$SCREENRC
fi
fi
@ -1523,8 +1523,8 @@ function _old_run_process {
exec 6>&-
if [[ -n ${SCREEN_LOGDIR} ]]; then
exec 1>&${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${1}.${CURRENT_LOG_TIME}.log ${SCREEN_LOGDIR}/screen-${1}.log
exec 1>&${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} 2>&1
ln -sf ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${1}.log
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs.
export PYTHONUNBUFFERED=1

View File

@ -20,7 +20,7 @@ set +o xtrace
# Defaults
# --------
# for DSTAT logging
DSTAT_FILE=${DSTAT_FILE:-"dstat.txt"}
DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
# start_dstat() - Start running processes, including screen

View File

@ -379,15 +379,14 @@ if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then
fi
if [[ -n "$LOGFILE" ]]; then
# First clean up old log files. Use the user-specified ``LOGFILE``
# as the template to search for, appending '.*' to match the date
# we added on earlier runs.
LOGDIR=$(dirname "$LOGFILE")
LOGFILENAME=$(basename "$LOGFILE")
mkdir -p $LOGDIR
find $LOGDIR -maxdepth 1 -name $LOGFILENAME.\* -mtime +$LOGDAYS -exec rm {} \;
# Clean up old log files. Append '.*' to the user-specified
# ``LOGFILE`` to match the date in the search template.
local logfile_dir="${LOGFILE%/*}" # dirname
local logfile_name="${LOGFILE##*/}" # basename
mkdir -p $logfile_dir
find $logfile_dir -maxdepth 1 -name $logfile_name.\* -mtime +$LOGDAYS -exec rm {} \;
LOGFILE=$LOGFILE.${CURRENT_LOG_TIME}
SUMFILE=$LOGFILE.${CURRENT_LOG_TIME}.summary
SUMFILE=$LOGFILE.summary.${CURRENT_LOG_TIME}
# Redirect output according to config
@ -408,8 +407,8 @@ if [[ -n "$LOGFILE" ]]; then
echo_summary "stack.sh log $LOGFILE"
# Specified logfile name always links to the most recent log
ln -sf $LOGFILE $LOGDIR/$LOGFILENAME
ln -sf $SUMFILE $LOGDIR/$LOGFILENAME.summary
ln -sf $LOGFILE $logfile_dir/$logfile_name
ln -sf $SUMFILE $logfile_dir/$logfile_name.summary
else
# Set up output redirection without log files
# Set fd 3 to a copy of stdout. So we can set fd 1 without losing