| ... | ... |
@@ -200,22 +200,19 @@ Enable Logging |
| 200 | 200 |
|
| 201 | 201 |
LOG_COLOR=False |
| 202 | 202 |
|
| 203 |
-Logging the Screen Output |
|
| 204 |
- |
|
| 205 |
- | *Default: ``SCREEN_LOGDIR=""``* |
|
| 206 |
- | By default DevStack runs the OpenStack services using ``screen`` |
|
| 207 |
- which is useful for watching log and debug output. However, in |
|
| 208 |
- automated testing the interactive ``screen`` sessions may not be |
|
| 209 |
- available after the fact; setting ``SCREEN_LOGDIR`` enables logging |
|
| 210 |
- of the ``screen`` sessions in the specified directory. There will be |
|
| 211 |
- one file per ``screen`` session named for the session name and a |
|
| 212 |
- timestamp. |
|
| 203 |
+Logging the Service Output |
|
| 204 |
+-------------------------- |
|
| 205 |
+ |
|
| 206 |
+ | *Default: ``LOGDIR=""``* |
|
| 207 |
+ | DevStack will log the stdout output of the services it starts. |
|
| 208 |
+ When using ``screen`` this logs the output in the screen windows |
|
| 209 |
+ to a file. Without ``screen`` this simply redirects stdout of |
|
| 210 |
+ the service process to a file in ``LOGDIR``. |
|
| 213 | 211 |
| |
| 214 | 212 |
|
| 215 | 213 |
:: |
| 216 | 214 |
|
| 217 |
- SCREEN_LOGDIR=$DEST/logs/screen |
|
| 215 |
+ LOGDIR=$DEST/logs |
|
| 218 | 216 |
|
| 219 | 217 |
*Note the use of ``DEST`` to locate the main install directory; this |
| 220 | 218 |
is why we suggest setting it in ``local.conf``.* |
| ... | ... |
@@ -400,8 +397,8 @@ Examples |
| 400 | 400 |
FIXED_RANGE=10.254.1.0/24 |
| 401 | 401 |
NETWORK_GATEWAY=10.254.1.1 |
| 402 | 402 |
LOGDAYS=1 |
| 403 |
- LOGFILE=$DEST/logs/stack.sh.log |
|
| 404 |
- SCREEN_LOGDIR=$DEST/logs/screen |
|
| 403 |
+ LOGDIR=$DEST/logs |
|
| 404 |
+ LOGFILE=$LOGDIR/stack.sh.log |
|
| 405 | 405 |
ADMIN_PASSWORD=quiet |
| 406 | 406 |
DATABASE_PASSWORD=$ADMIN_PASSWORD |
| 407 | 407 |
RABBIT_PASSWORD=$ADMIN_PASSWORD |
| ... | ... |
@@ -319,8 +319,8 @@ function err {
|
| 319 | 319 |
set +o xtrace |
| 320 | 320 |
local msg="[ERROR] ${BASH_SOURCE[2]}:$1 $2"
|
| 321 | 321 |
echo $msg 1>&2; |
| 322 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 323 |
- echo $msg >> "${SCREEN_LOGDIR}/error.log"
|
|
| 322 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 323 |
+ echo $msg >> "${LOGDIR}/error.log"
|
|
| 324 | 324 |
fi |
| 325 | 325 |
$xtrace |
| 326 | 326 |
return $exitcode |
| ... | ... |
@@ -372,8 +372,8 @@ function warn {
|
| 372 | 372 |
set +o xtrace |
| 373 | 373 |
local msg="[WARNING] ${BASH_SOURCE[2]}:$1 $2"
|
| 374 | 374 |
echo $msg 1>&2; |
| 375 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 376 |
- echo $msg >> "${SCREEN_LOGDIR}/error.log"
|
|
| 375 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 376 |
+ echo $msg >> "${LOGDIR}/error.log"
|
|
| 377 | 377 |
fi |
| 378 | 378 |
$xtrace |
| 379 | 379 |
return $exitcode |
| ... | ... |
@@ -1261,8 +1261,8 @@ function zypper_install {
|
| 1261 | 1261 |
# _run_process() is designed to be backgrounded by run_process() to simulate a |
| 1262 | 1262 |
# fork. It includes the dirty work of closing extra filehandles and preparing log |
| 1263 | 1263 |
# files to produce the same logs as screen_it(). The log filename is derived |
| 1264 |
-# from the service name and global-and-now-misnamed ``SCREEN_LOGDIR`` |
|
| 1265 |
-# Uses globals ``CURRENT_LOG_TIME``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
| 1264 |
+# from the service name. |
|
| 1265 |
+# Uses globals ``CURRENT_LOG_TIME``, ``LOGDIR``, ``SCREEN_LOGDIR``, ``SCREEN_NAME``, ``SERVICE_DIR`` |
|
| 1266 | 1266 |
# If an optional group is provided sg will be used to set the group of |
| 1267 | 1267 |
# the command. |
| 1268 | 1268 |
# _run_process service "command-line" [group] |
| ... | ... |
@@ -1277,9 +1277,14 @@ function _run_process {
|
| 1277 | 1277 |
exec 3>&- |
| 1278 | 1278 |
exec 6>&- |
| 1279 | 1279 |
|
| 1280 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1281 |
- exec 1>&${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} 2>&1
|
|
| 1282 |
- ln -sf ${SCREEN_LOGDIR}/screen-${service}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${service}.log
|
|
| 1280 |
+ local real_logfile="${LOGDIR}/${service}.log.${CURRENT_LOG_TIME}"
|
|
| 1281 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 1282 |
+ exec 1>&"$real_logfile" 2>&1 |
|
| 1283 |
+ ln -sf "$real_logfile" ${LOGDIR}/${service}.log
|
|
| 1284 |
+ if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1285 |
+ # Drop the backward-compat symlink |
|
| 1286 |
+ ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${service}.log
|
|
| 1287 |
+ fi |
|
| 1283 | 1288 |
|
| 1284 | 1289 |
# TODO(dtroyer): Hack to get stdout from the Python interpreter for the logs. |
| 1285 | 1290 |
export PYTHONUNBUFFERED=1 |
| ... | ... |
@@ -1343,7 +1348,7 @@ function run_process {
|
| 1343 | 1343 |
} |
| 1344 | 1344 |
|
| 1345 | 1345 |
# Helper to launch a process in a named screen |
| 1346 |
-# Uses globals ``CURRENT_LOG_TIME``, ``SCREEN_NAME``, ``SCREEN_LOGDIR``, |
|
| 1346 |
+# Uses globals ``CURRENT_LOG_TIME``, ```LOGDIR``, ``SCREEN_LOGDIR``, `SCREEN_NAME``, |
|
| 1347 | 1347 |
# ``SERVICE_DIR``, ``USE_SCREEN`` |
| 1348 | 1348 |
# screen_process name "command-line" [group] |
| 1349 | 1349 |
# Run a command in a shell in a screen window, if an optional group |
| ... | ... |
@@ -1362,10 +1367,18 @@ function screen_process {
|
| 1362 | 1362 |
|
| 1363 | 1363 |
screen -S $SCREEN_NAME -X screen -t $name |
| 1364 | 1364 |
|
| 1365 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1366 |
- screen -S $SCREEN_NAME -p $name -X logfile ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME}
|
|
| 1365 |
+ local real_logfile="${LOGDIR}/${name}.log.${CURRENT_LOG_TIME}"
|
|
| 1366 |
+ echo "LOGDIR: $LOGDIR" |
|
| 1367 |
+ echo "SCREEN_LOGDIR: $SCREEN_LOGDIR" |
|
| 1368 |
+ echo "log: $real_logfile" |
|
| 1369 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 1370 |
+ screen -S $SCREEN_NAME -p $name -X logfile "$real_logfile" |
|
| 1367 | 1371 |
screen -S $SCREEN_NAME -p $name -X log on |
| 1368 |
- ln -sf ${SCREEN_LOGDIR}/screen-${name}.log.${CURRENT_LOG_TIME} ${SCREEN_LOGDIR}/screen-${name}.log
|
|
| 1372 |
+ ln -sf "$real_logfile" ${LOGDIR}/${name}.log
|
|
| 1373 |
+ if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1374 |
+ # Drop the backward-compat symlink |
|
| 1375 |
+ ln -sf "$real_logfile" ${SCREEN_LOGDIR}/screen-${1}.log
|
|
| 1376 |
+ fi |
|
| 1369 | 1377 |
fi |
| 1370 | 1378 |
|
| 1371 | 1379 |
# sleep to allow bash to be ready to be send the command - we are |
| ... | ... |
@@ -1410,8 +1423,8 @@ function screen_rc {
|
| 1410 | 1410 |
echo "screen -t $1 bash" >> $SCREENRC |
| 1411 | 1411 |
echo "stuff \"$2$NL\"" >> $SCREENRC |
| 1412 | 1412 |
|
| 1413 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 1414 |
- echo "logfile ${SCREEN_LOGDIR}/screen-${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
|
|
| 1413 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 1414 |
+ echo "logfile ${LOGDIR}/${1}.log.${CURRENT_LOG_TIME}" >>$SCREENRC
|
|
| 1415 | 1415 |
echo "log on" >>$SCREENRC |
| 1416 | 1416 |
fi |
| 1417 | 1417 |
fi |
| ... | ... |
@@ -27,8 +27,12 @@ DSTAT_FILE=${DSTAT_FILE:-"dstat.log"}
|
| 27 | 27 |
function start_dstat {
|
| 28 | 28 |
# A better kind of sysstat, with the top process per time slice |
| 29 | 29 |
DSTAT_OPTS="-tcmndrylpg --top-cpu-adv --top-io-adv" |
| 30 |
- if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 31 |
- screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $SCREEN_LOGDIR/$DSTAT_FILE" |
|
| 30 |
+ if [[ -n ${LOGDIR} ]]; then
|
|
| 31 |
+ screen_it dstat "cd $TOP_DIR; dstat $DSTAT_OPTS | tee $LOGDIR/$DSTAT_FILE" |
|
| 32 |
+ if [[ -n ${SCREEN_LOGDIR} ]]; then
|
|
| 33 |
+ # Drop the backward-compat symlink |
|
| 34 |
+ ln -sf $LOGDIR/$DSTAT_FILE ${SCREEN_LOGDIR}/$DSTAT_FILE
|
|
| 35 |
+ fi |
|
| 32 | 36 |
else |
| 33 | 37 |
screen_it dstat "dstat $DSTAT_OPTS" |
| 34 | 38 |
fi |
| ... | ... |
@@ -349,10 +349,8 @@ function echo_nolog {
|
| 349 | 349 |
# Append '.xxxxxxxx' to the given name to maintain history |
| 350 | 350 |
# where 'xxxxxxxx' is a representation of the date the file was created |
| 351 | 351 |
TIMESTAMP_FORMAT=${TIMESTAMP_FORMAT:-"%F-%H%M%S"}
|
| 352 |
-if [[ -n "$LOGFILE" || -n "$SCREEN_LOGDIR" ]]; then |
|
| 353 |
- LOGDAYS=${LOGDAYS:-7}
|
|
| 354 |
- CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT") |
|
| 355 |
-fi |
|
| 352 |
+LOGDAYS=${LOGDAYS:-7}
|
|
| 353 |
+CURRENT_LOG_TIME=$(date "+$TIMESTAMP_FORMAT") |
|
| 356 | 354 |
|
| 357 | 355 |
if [[ -n "$LOGFILE" ]]; then |
| 358 | 356 |
# Clean up old log files. Append '.*' to the user-specified |
| ... | ... |
@@ -404,6 +402,7 @@ fi |
| 404 | 404 |
# ``screen-$SERVICE_NAME-$TIMESTAMP.log`` in that dir and have a link |
| 405 | 405 |
# ``screen-$SERVICE_NAME.log`` to the latest log file. |
| 406 | 406 |
# Logs are kept for as long specified in ``LOGDAYS``. |
| 407 |
+# This is deprecated....logs go in ``LOGDIR``, only symlinks will be here now. |
|
| 407 | 408 |
if [[ -n "$SCREEN_LOGDIR" ]]; then |
| 408 | 409 |
|
| 409 | 410 |
# We make sure the directory is created. |
| ... | ... |
@@ -705,6 +705,53 @@ USE_SSL=$(trueorfalse False USE_SSL) |
| 705 | 705 |
|
| 706 | 706 |
# Following entries need to be last items in file |
| 707 | 707 |
|
| 708 |
+# Compatibility bits required by other callers like Grenade |
|
| 709 |
+ |
|
| 710 |
+# Old way was using SCREEN_LOGDIR to locate those logs and LOGFILE for the stack.sh trace log. |
|
| 711 |
+# LOGFILE SCREEN_LOGDIR output |
|
| 712 |
+# not set not set no log files |
|
| 713 |
+# set not set stack.sh log to LOGFILE |
|
| 714 |
+# not set set screen logs to SCREEN_LOGDIR |
|
| 715 |
+# set set stack.sh log to LOGFILE, screen logs to SCREEN_LOGDIR |
|
| 716 |
+ |
|
| 717 |
+# New way is LOGDIR for all logs and LOGFILE for stack.sh trace log, but if not fully-qualified will be in LOGDIR |
|
| 718 |
+# LOGFILE LOGDIR output |
|
| 719 |
+# not set not set (new) set LOGDIR from default |
|
| 720 |
+# set not set stack.sh log to LOGFILE, (new) set LOGDIR from LOGFILE |
|
| 721 |
+# not set set screen logs to LOGDIR |
|
| 722 |
+# set set stack.sh log to LOGFILE, screen logs to LOGDIR |
|
| 723 |
+ |
|
| 724 |
+# For compat, if SCREEN_LOGDIR is set, it will be used to create back-compat symlinks to the LOGDIR |
|
| 725 |
+# symlinks to SCREEN_LOGDIR (compat) |
|
| 726 |
+ |
|
| 727 |
+ |
|
| 728 |
+# Set up new logging defaults |
|
| 729 |
+if [[ -z "${LOGDIR:-}" ]]; then
|
|
| 730 |
+ default_logdir=$DEST/logs |
|
| 731 |
+ if [[ -z "${LOGFILE:-}" ]]; then
|
|
| 732 |
+ # Nothing is set, we need a default |
|
| 733 |
+ LOGDIR="$default_logdir" |
|
| 734 |
+ else |
|
| 735 |
+ # Set default LOGDIR |
|
| 736 |
+ LOGDIR="${LOGFILE%/*}"
|
|
| 737 |
+ logfile="${LOGFILE##*/}"
|
|
| 738 |
+ if [[ -z "$LOGDIR" || "$LOGDIR" == "$logfile" ]]; then |
|
| 739 |
+ # LOGFILE had no path, set a default |
|
| 740 |
+ LOGDIR="$default_logdir" |
|
| 741 |
+ fi |
|
| 742 |
+ |
|
| 743 |
+ # Check for duplication |
|
| 744 |
+ if [[ "${SCREEN_LOGDIR:-}" == "${LOGDIR}" ]]; then
|
|
| 745 |
+ # We don't need the symlinks since it's the same directory |
|
| 746 |
+ unset SCREEN_LOGDIR |
|
| 747 |
+ fi |
|
| 748 |
+ fi |
|
| 749 |
+ unset default_logdir logfile |
|
| 750 |
+fi |
|
| 751 |
+ |
|
| 752 |
+# LOGDIR is always set at this point so it is not useful as a 'enable' for service logs |
|
| 753 |
+# SCREEN_LOGDIR may be set, it is useful to enable the compat symlinks |
|
| 754 |
+ |
|
| 708 | 755 |
# Local variables: |
| 709 | 756 |
# mode: shell-script |
| 710 | 757 |
# End: |