From 73ebd4cddb3946b7cc56db0fcf392c8ca03192c1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 16 Jul 2024 09:39:10 +0200 Subject: [PATCH] Improve deploy cron to log duration (and log file in case of error) --- check_container_upgrade | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/check_container_upgrade b/check_container_upgrade index 4d4d4bc..8c94d5b 100755 --- a/check_container_upgrade +++ b/check_container_upgrade @@ -319,12 +319,14 @@ if [[ $DEPLOY_CRON -eq 1 ]]; then for container in "${to_deploy[@]}"; do message " $container: deploying..." log="$REBUILD_DATA_DIR/$container.log" - if $COMPOSE_BIN -f "$DOCKERCOMPOSE_FILE" up -d --no-deps "$container" > "$log" 2>&1; then - message " $container: done" + start_time=$(current_time) + if $COMPOSE_BIN -f "$DOCKERCOMPOSE_FILE" up -d --no-deps "$container" >> "$log" 2>&1; then + message " $container: done (in $(format_duration "$(( $(current_time)-start_time ))"))" update_rebuild_status -d "$container" rm -f "$log" else - error " $container: fail to deploy new container image" + error " $container: fail to deploy new container image (in" \ + "$(format_duration "$(( $(current_time)-start_time ))"), see log: $log)" update_rebuild_status "$container" "error=fail to deploy new container image" error=1 fi