Export logs to LOG_DIR

This commit is contained in:
Abhishek Kumar 2025-09-26 12:28:05 +05:30
parent 39dade1755
commit 1349887649
2 changed files with 8 additions and 7 deletions

View file

@ -6,7 +6,7 @@ set -e # Exit on error
### CONFIGURATION #############################################################
ENV_FILE="api/.env"
RUN_DIR="run"
LOG_ROOT="logs"
LOG_DIR="logs"
VENV_PATH="/home/ubuntu/dograh_venv"
HEALTH_CHECK_ENDPOINT="/api/v1/health" # Adjust as needed
MAX_WAIT_SECONDS=310 # Max wait for graceful shutdown (5 minutes + 10 seconds grace)
@ -14,6 +14,8 @@ MAX_WAIT_SECONDS=310 # Max wait for graceful shutdown (5 minutes + 10 seconds g
# Load environment
set -a && . "$ENV_FILE" && set +a
cd /home/ubuntu/app
### FUNCTIONS ##################################################################
log_info() {
@ -142,11 +144,11 @@ start_new_uvicorn_workers() {
# Activate virtual environment
source ${VENV_PATH}/bin/activate
# Use the latest log directory (where start_services.sh put logs)
local log_dir="$LOG_ROOT/latest"
# Use the log directory (where start_services.sh put logs)
local log_dir="$LOG_DIR"
if [[ ! -d "$log_dir" ]]; then
log_error "No latest log directory found. Run start_services.sh first."
log_error "No log directory found. Run start_services.sh first."
return 1
fi
@ -304,5 +306,5 @@ echo "✓ Rolling update completed successfully"
echo " Old port: ${OLD_PORT:-none}"
echo " New port: $NEW_PORT"
echo " New PID: $NEW_PID"
echo " Logs: $LOG_ROOT/latest/"
echo " Logs: $LOG_DIR/"
echo "──────────────────────────────────────────────────"

View file

@ -6,7 +6,7 @@ set -e # Exit on error
### CONFIGURATION #############################################################
ENV_FILE="api/.env"
RUN_DIR="run" # where we keep *.pid
LOG_ROOT="logs"
LOG_DIR="logs"
VENV_PATH="/home/ubuntu/dograh_venv"
ARQ_WORKERS=${ARQ_WORKERS:-1}
@ -75,7 +75,6 @@ rm -f "$RUN_DIR/uvicorn.port" "$RUN_DIR/uvicorn_new.port" "$RUN_DIR/uvicorn_old.
alembic -c api/alembic.ini upgrade head
### 5) Prepare logs ###########################################################
LOG_DIR="$LOG_ROOT/latest"
mkdir -p "$LOG_DIR"
### 7) Start services #########################################################