From 1f36ade7de38abb2fa07583c8685c6bc783c0e91 Mon Sep 17 00:00:00 2001 From: infosave2007 Date: Mon, 10 Nov 2025 16:09:21 +0300 Subject: [PATCH] feat: improve metrics collector handling by starting it if not running and logging status --- update.sh | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 65c8abd..b625900 100755 --- a/update.sh +++ b/update.sh @@ -669,10 +669,24 @@ if [ -n "$METRICS_PID" ]; then if $DOCKER_COMPOSE exec -T web ps -p "$METRICS_PID" &>/dev/null; then log_success "Metrics collector is running (PID: $METRICS_PID)" else - log_warning "Metrics collector PID file exists but process not found, will restart via cron" + log_warning "Metrics collector PID file exists but process not found, starting..." + $DOCKER_COMPOSE exec -d web /bin/bash /var/www/html/bin/monitor_metrics.sh + sleep 3 + NEW_PID=$($DOCKER_COMPOSE exec -T web cat /var/run/collect_metrics.pid 2>/dev/null || echo "") + if [ -n "$NEW_PID" ]; then + log_success "Metrics collector started (PID: $NEW_PID)" + fi fi else - log_warning "Metrics collector not running, will be started by cron within 3 minutes" + log_warning "Metrics collector not running, starting now..." + $DOCKER_COMPOSE exec -d web /bin/bash /var/www/html/bin/monitor_metrics.sh + sleep 3 + NEW_PID=$($DOCKER_COMPOSE exec -T web cat /var/run/collect_metrics.pid 2>/dev/null || echo "") + if [ -n "$NEW_PID" ]; then + log_success "Metrics collector started (PID: $NEW_PID)" + else + log_warning "Failed to start metrics collector. Check: docker-compose exec web tail /var/log/metrics_monitor.log" + fi fi # ==========================================