From 89ecc28f2e3575be0be6d16f4d132e21bac71ebc Mon Sep 17 00:00:00 2001 From: Roman Loginov Date: Fri, 16 Aug 2024 09:08:11 +0300 Subject: [PATCH] [#30] Rework logging in the container Signed-off-by: Roman Loginov --- .env | 2 +- Makefile | 9 +++++++++ README.md | 16 ++++++++++++++++ bin/init-aio.sh | 10 +++++----- docker-compose.yml | 2 ++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.env b/.env index d6a68f3..3461c27 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ FROSTFS_HUB_IMAGE=truecloudlab/frostfs AIO_IMAGE=truecloudlab/frostfs-aio -AIO_VERSION=1.5.0 +AIO_VERSION=1.5.1 diff --git a/Makefile b/Makefile index c045e53..c62e521 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ VERSION ?= "$(shell git describe --tags --match "v*" 2>/dev/null || git rev-pars # Variables for docker AIO_IMAGE ?= "truecloudlab/frostfs-aio" +LOG_DIR ?= "/var/log" # Variables for compose COMPOSE_CMD_UP ?= docker-compose up -d @@ -96,3 +97,11 @@ version: @echo $(VERSION) @echo "frostfs-node: $(AIO_VERSION)" @echo "neo-go: $(NEOGO_VERSION)" + +# Show all logs of the FrostFS service +logs/%: + @docker exec aio cat ${LOG_DIR}/$* + +# Streaming of the frostFS service logs +logs-stream/%: + @docker exec aio tail -f ${LOG_DIR}/$* diff --git a/README.md b/README.md index 2006b92..60c4c68 100644 --- a/README.md +++ b/README.md @@ -324,3 +324,19 @@ $ frostfs-cli -r localhost:8080 -w /config/user-wallet.json \ --cid GfWw35kHds7gKWmSvW7Zi4U39K7NMLK8EfXBQ5FPJA46 \ --oid HByVC9A34i22BnzW3n83z9vEMxuYZoC7nNu11ZvGeCTe > new_cat.jpg ``` + +## Viewing logs + +There are two targets for viewing logs. + +You can view all the logs by replacing the desired service name: + +``` sh +make logs/frostfs-node +``` + +You can also make a continuous stream of logs by replacing the desired service name: + +``` sh +make stream-logs/frostfs-node +``` diff --git a/bin/init-aio.sh b/bin/init-aio.sh index d38a3c2..721e9d2 100755 --- a/bin/init-aio.sh +++ b/bin/init-aio.sh @@ -14,7 +14,7 @@ die() { runBlockchain() { stage "Starting the blockchain" - /usr/bin/neo-go node --config-path /config --privnet & + /usr/bin/neo-go node --config-path /config --privnet |& tee -a ${LOG_DIR}/neo-go & while [[ "$(curl -s -o /dev/null -w %{http_code} localhost:30333)" != "422" ]]; do @@ -37,7 +37,7 @@ configure() { runServices() { stage "Running services" - /usr/bin/frostfs-ir --config /config/config-ir.yaml & + /usr/bin/frostfs-ir --config /config/config-ir.yaml |& tee -a ${LOG_DIR}/frostfs-ir & while [[ -z "$(/usr/bin/frostfs-cli control ir healthcheck --endpoint localhost:16512 -c /config/cli-cfg-ir.yaml | grep 'Health status: READY')" ]]; do @@ -45,7 +45,7 @@ runServices() { done set -m - /usr/bin/frostfs-node --config /config/config-sn.yaml & + /usr/bin/frostfs-node --config /config/config-sn.yaml |& tee -a ${LOG_DIR}/frostfs-node & while [[ -z "$(/usr/bin/frostfs-cli control healthcheck --endpoint localhost:16513 -c /config/cli-cfg-sn.yaml | grep 'Health status: READY')" ]]; do @@ -63,8 +63,8 @@ runServices() { sleep 2 done - /usr/bin/frostfs-s3-gw --config /config/s3-gw-config.yaml & - /usr/bin/frostfs-http-gw --config /config/http-gw-config.yaml & + /usr/bin/frostfs-s3-gw --config /config/s3-gw-config.yaml |& tee -a ${LOG_DIR}/frostfs-s3-gw & + /usr/bin/frostfs-http-gw --config /config/http-gw-config.yaml |& tee -a ${LOG_DIR}/frostfs-http-gw & } diff --git a/docker-compose.yml b/docker-compose.yml index b803fd0..5dbed75 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,8 @@ services: retries: 100 start_period: 2s timeout: 2s + environment: + - LOG_DIR=/var/log volumes: - data:/data - ./wallets:/wallets