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:
@@ -3,14 +3,18 @@
|
||||
# Launches a dockerized service defined by a docker-compose.yml file.
|
||||
# This is a general purpose launcher, doesn't requires customization.
|
||||
# Actually it is a humble wrapper script for a 'docker-compose up -d'
|
||||
# command. Additionally sets up an aggregated logfile or per-service
|
||||
# logfiles and prevents the multiple launch attempts.
|
||||
# command. Additionally may set up an aggregated logfile and rejects
|
||||
# all multiple launch attempts.
|
||||
#
|
||||
# Author: Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# Author: Kovács Zoltán <kovacsz@marcusconsulting.hu>
|
||||
# Kovács Zoltán <kovacs.zoltan@smartfront.hu>
|
||||
# License: GNU/GPL v3+ (https://www.gnu.org/licenses/gpl-3.0.en.html)
|
||||
#
|
||||
# 2025-02-02 v1.3
|
||||
# mod: Only handles the aggregate log, per-service logging has been
|
||||
# outsourced to a new code snippet.
|
||||
# 2025-02-02 v1.2
|
||||
# fix: unwanted error message in old docker-compose detection.
|
||||
# fix: Unwanted error message in old docker-compose detection.
|
||||
# 2024-08-24 v1.1
|
||||
# new: docker-compose v2 compatibility - tested with Ubuntu 24.04 LTS.
|
||||
# 2023-06-18 v1.0
|
||||
@@ -91,20 +95,11 @@ fi
|
||||
# Starts the service.
|
||||
(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring up -d)
|
||||
|
||||
|
||||
# Starts the logger - this/these process(es) will automatically terminate
|
||||
# when the docker-compose stops.
|
||||
# Starts the aggregated logger on request - this process will automatically terminate
|
||||
# when the composition stops.
|
||||
if [ -n "$PAR_AGGLOGS" ]; then
|
||||
# Aggregated logs
|
||||
(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring logs --no-color -t -f >> "$BASE_DIR/$LOGFILE" &)
|
||||
else
|
||||
# Separate logs, each for every running service.
|
||||
for service in $(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring ps --services) ""
|
||||
do
|
||||
if [ -n "$service" ]; then
|
||||
(cd "$BASE_DIR"; "$DOCKER_COMPOSE" $commandstring logs --no-color -t -f $service >> "$BASE_DIR/$LOGDIR/$service.log" &)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# That's all, Folks!
|
||||
|
Reference in New Issue
Block a user