From 043753782467ad99b77f80739a87bc17be4ece9f Mon Sep 17 00:00:00 2001 From: Stephan Barth Date: Mon, 4 Nov 2024 17:28:01 +0100 Subject: [PATCH] build(Makefile): make 'make log' work; mv containerfiles to .exited. --- Makefile | 14 ++++++++++++-- utils/watchcontainerrun.sh | 4 +++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b980da707..a6853228e 100644 --- a/Makefile +++ b/Makefile @@ -259,11 +259,21 @@ well-known: static; status: @./utils/develop-status.pl -a -# TODO: rework logs +# TODO: rework logs, because they do not work .PHONY: log-% # HELP(log-{database,memcached,minio,backend,frontend,hoogle}): inspect output of a given (currently running) service. When a service supports multiple running instances in one develop (i.e. backend), you need to specify the exact instance by its associated file (e.g. backend-1, backend-2, etc.), please check the contents of the develop/ directory for a list of running instances. log-%: - $(CONTAINER_COMMAND) logs --follow `cat $(DEVELOP)/$* | grep CONTAINER_ID= | sed 's/^CONTAINER_ID=//'` + DEVELOP=develop/`cat develop/.current` ; \ + SEARCH_FILE="$${DEVELOP}/$*" ; \ + if [[ ! -e "$${SEARCH_FILE}" ]] ; then \ + SEARCH_FILE="$${DEVELOP}/.exited.$*" ; \ + fi ; \ + if [[ -e "$${SEARCH_FILE}" ]] ; then \ + $(CONTAINER_COMMAND) logs --follow `cat "$${SEARCH_FILE}" | grep CONTAINER_ID= | sed 's/^CONTAINER_ID=//'` ; \ + else \ + >&2 echo "Cannot show log: No develop file found for '$*'" ; \ + exit 1 ; \ + fi .PHONY: enter # HELP: launch (bash) shell inside a currently running container. Use ./enter shell wrapper for more convenient usage, possibly with tab-completion in the future diff --git a/utils/watchcontainerrun.sh b/utils/watchcontainerrun.sh index eb2073024..3e0bc91a0 100755 --- a/utils/watchcontainerrun.sh +++ b/utils/watchcontainerrun.sh @@ -29,7 +29,9 @@ $STARTSCRIPT while [ -e "$FILENAME" ] ; do sleep 1 if ! $RUNNER ps --no-trunc | grep -q "$CONTAINER_ID" ; then - rm "$FILENAME" + #rm "$FILENAME" + EXITED_FILENAME=`echo "$FILENAME" | sed 's/\([^\/]*\)$/.exited.\1/'` + mv "$FILENAME" "$EXITED_FILENAME" exit fi inotifywait -e ATTRIB -t 10 "$FILENAME" > /dev/null 2>/dev/null