Per-service logging enhancements
* per-service logging feature restarts automatically on reboot * a new worker script: tools/startup.d/110-startlogs.sh * using docker logs instead of docker compose logs cause format changes
This commit is contained in:
@ -6,13 +6,27 @@
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
#
|
||||
# 2025-02-02 v1.1
|
||||
# new: On reboot (re)starts the per-service logger feature.
|
||||
# 2023-06-18 v1.0
|
||||
# new: forked from the "Smartfront's DOCKER_skeleton" repository.
|
||||
# 2021.08-30 v0.1 Initial release
|
||||
# 2021-08-30 v0.1 Initial release
|
||||
|
||||
# Accepted environment variables and their defaults.
|
||||
#
|
||||
PAR_BASEDIR=${PAR_BASEDIR:-""} # Service's base folder
|
||||
PAR_AGGLOGS=${PAR_AGGLOGS:-""} # Not empty for aggregated logs
|
||||
|
||||
# Other initialisations.
|
||||
#
|
||||
START_LOGGER="tools/startup.d/110-startlogs.sh"
|
||||
YMLFILE="docker-compose.yml"
|
||||
|
||||
# Messages.
|
||||
#
|
||||
MSG_MISSINGDEP="Fatal: missing dependency"
|
||||
MSG_MISSINGYML="Fatal: didn't find the docker-compose.yml file"
|
||||
|
||||
# Checks the dependencies.
|
||||
#
|
||||
@ -28,6 +42,7 @@ done
|
||||
|
||||
# Where I'm?
|
||||
# https://gist.github.com/TheMengzor/968e5ea87e99d9c41782
|
||||
#
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do
|
||||
# resolve $SOURCE until the file is no longer a symlink
|
||||
@ -39,4 +54,27 @@ while [ -h "$SOURCE" ]; do
|
||||
done; SCRPATH="$( cd -P "$( "$DIRNAME" "$SOURCE" )" && pwd )" #"
|
||||
SCRFILE="$("$BASENAME" "$(test -L "$0" && "$READLINK" "$0" || echo "$0")")" #"
|
||||
|
||||
# Actually this job does nothing.
|
||||
# Searches the base folder, containing a docker-compose.yml file.
|
||||
#
|
||||
# Called from the base folder (./)?
|
||||
BASE_DIR="$PAR_BASEDIR"
|
||||
TEST_DIR="$SCRPATH"
|
||||
[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR"
|
||||
# Called from ./tools?
|
||||
TEST_DIR="$("$DIRNAME" "$TEST_DIR")"
|
||||
[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR"
|
||||
# Called from ./tools/*.d?
|
||||
TEST_DIR="$("$DIRNAME" "$TEST_DIR")"
|
||||
[[ -z "$BASE_DIR" ]] && [[ -r "$TEST_DIR/$YMLFILE" ]] && BASE_DIR="$TEST_DIR"
|
||||
# On failure gives it up here.
|
||||
if [ -z "$BASE_DIR" -o ! -r "$BASE_DIR/$YMLFILE" ]; then
|
||||
echo "$MSG_MISSINGYML" >&2; exit 1
|
||||
fi
|
||||
|
||||
# Starts per-service logging if it is not already running.
|
||||
#
|
||||
if [ -x "$BASE_DIR/$START_LOGGER" ]; then
|
||||
"$BASE_DIR/$START_LOGGER"
|
||||
fi
|
||||
|
||||
# That's all, Folks :)
|
||||
|
Reference in New Issue
Block a user