diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/cron/CleanUpOldLogs.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/cron/CleanUpOldLogs.java index c2d7dffb54..f917bfb844 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/cron/CleanUpOldLogs.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/cron/CleanUpOldLogs.java @@ -24,7 +24,7 @@ public class CleanUpOldLogs { final long cutoffTime = System.currentTimeMillis() - CUTOFF_AGE; - try (Stream walk = Files.walk(Paths.get("/appsmith-stacks/logs"))) { + try (Stream walk = Files.walk(Paths.get(System.getenv("APPSMITH_LOG_DIR")))) { walk.filter(path -> { try { return Files.isRegularFile(path) diff --git a/deploy/docker/fs/etc/supervisor/supervisord.conf b/deploy/docker/fs/etc/supervisor/supervisord.conf index 8c589e5fa7..e3b341fca6 100644 --- a/deploy/docker/fs/etc/supervisor/supervisord.conf +++ b/deploy/docker/fs/etc/supervisor/supervisord.conf @@ -10,9 +10,9 @@ username=%(ENV_APPSMITH_SUPERVISOR_USER)s password=%(ENV_APPSMITH_SUPERVISOR_PASSWORD)s [supervisord] -logfile=/appsmith-stacks/logs/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +logfile=%(ENV_APPSMITH_LOG_DIR)s/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) pidfile=%(ENV_TMP)s/supervisord.pid ; (supervisord pidfile;default supervisord.pid) -childlogdir=/appsmith-stacks/logs/supervisor ; ('AUTO' child log dir, default $TEMP) +childlogdir=%(ENV_APPSMITH_LOG_DIR)s/supervisor ; ('AUTO' child log dir, default $TEMP) stdout_logfile_maxbytes = 0 stderr_logfile_maxbytes = 0 diff --git a/deploy/docker/fs/opt/appsmith/entrypoint.sh b/deploy/docker/fs/opt/appsmith/entrypoint.sh index 541416edd3..bf9050d470 100644 --- a/deploy/docker/fs/opt/appsmith/entrypoint.sh +++ b/deploy/docker/fs/opt/appsmith/entrypoint.sh @@ -454,7 +454,7 @@ function setup_auto_heal(){ if [[ ${APPSMITH_AUTO_HEAL-} = 1 ]]; then # By default APPSMITH_AUTO_HEAL=0 # To enable auto heal set APPSMITH_AUTO_HEAL=1 - bash /opt/appsmith/auto_heal.sh $APPSMITH_AUTO_HEAL_CURL_TIMEOUT >> /appsmith-stacks/logs/cron/auto_heal.log 2>&1 & + bash /opt/appsmith/auto_heal.sh $APPSMITH_AUTO_HEAL_CURL_TIMEOUT >> "$APPSMITH_LOG_DIR"/cron/auto_heal.log 2>&1 & fi } @@ -490,7 +490,8 @@ configure_supervisord mkdir -p /appsmith-stacks/data/{backup,restore} /appsmith-stacks/ssl # Create sub-directory to store services log in the container mounting folder -mkdir -p /appsmith-stacks/logs/{supervisor,backend,cron,editor,rts,mongodb,redis,postgres,appsmithctl} +export APPSMITH_LOG_DIR="${APPSMITH_LOG_DIR:-/appsmith-stacks/logs}" +mkdir -p "$APPSMITH_LOG_DIR"/{supervisor,backend,cron,editor,rts,mongodb,redis,postgres,appsmithctl} setup_auto_heal diff --git a/deploy/docker/fs/opt/appsmith/starting-page-init.py b/deploy/docker/fs/opt/appsmith/starting-page-init.py index b0ec2b3113..edd793977f 100644 --- a/deploy/docker/fs/opt/appsmith/starting-page-init.py +++ b/deploy/docker/fs/opt/appsmith/starting-page-init.py @@ -1,7 +1,7 @@ import atexit import logging import os -import shutil +import os.path import subprocess import time import urllib.error @@ -10,7 +10,7 @@ import urllib.request LOADING_PAGE_EDITOR = os.getenv("WWW_PATH") + '/loading.html' BACKEND_HEALTH_ENDPOINT = "http://localhost:8080/api/v1/health" -LOG_FILE = r'/appsmith-stacks/logs/backend/starting_page_init.log' +LOG_FILE = os.path.join(os.getenv("APPSMITH_LOG_DIR"), "backend", "starting_page_init.log") LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' logging.basicConfig(filename = LOG_FILE, level = logging.NOTSET, format = LOG_FORMAT) diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/backend.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/backend.conf index ecd505683b..be1d8cd57e 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/backend.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/backend.conf @@ -6,7 +6,7 @@ autostart=true autorestart=true startsecs=20 startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/%(program_name)s-%(ENV_HOSTNAME)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/%(program_name)s-%(ENV_HOSTNAME)s.log redirect_stderr=true stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/editor.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/editor.conf index 0b7ab6d0e5..8fa54215d5 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/editor.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/editor.conf @@ -5,8 +5,8 @@ autostart=true autorestart=true startsecs=0 startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/access-%(ENV_HOSTNAME)s.log -stderr_logfile=/appsmith-stacks/logs/%(program_name)s/error-%(ENV_HOSTNAME)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/access-%(ENV_HOSTNAME)s.log +stderr_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/error-%(ENV_HOSTNAME)s.log stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB stdout_logfile_backups=2 diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf index 9f94487204..6900f17a17 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/application_process/rts.conf @@ -6,7 +6,7 @@ autostart=true autorestart=true startsecs=0 startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/%(program_name)s-%(ENV_HOSTNAME)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/%(program_name)s-%(ENV_HOSTNAME)s.log redirect_stderr=true stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/mongodb.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/mongodb.conf index 6a9fd3b13b..7e7b0a7bd3 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/mongodb.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/mongodb.conf @@ -1,12 +1,12 @@ [program:mongodb] directory=/appsmith-stacks/data/mongodb -command=mongod --port 27017 --dbpath . --logpath /appsmith-stacks/logs/%(program_name)s/db.log --replSet mr1 --keyFile %(ENV_MONGODB_TMP_KEY_PATH)s --bind_ip localhost +command=mongod --port 27017 --dbpath . --logpath %(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/db.log --replSet mr1 --keyFile %(ENV_MONGODB_TMP_KEY_PATH)s --bind_ip localhost priority=10 autostart=true autorestart=true startsecs=10 startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/%(program_name)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/%(program_name)s.log redirect_stderr=true stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/postgres.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/postgres.conf index a3b4b0486d..2dd1aa8d05 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/postgres.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/postgres.conf @@ -5,7 +5,7 @@ command=/opt/appsmith/run-postgres.sh autostart=true autorestart=true startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/%(program_name)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/%(program_name)s.log redirect_stderr=true stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB diff --git a/deploy/docker/fs/opt/appsmith/templates/supervisord/redis.conf b/deploy/docker/fs/opt/appsmith/templates/supervisord/redis.conf index 0a0a738905..5fb91c84fe 100644 --- a/deploy/docker/fs/opt/appsmith/templates/supervisord/redis.conf +++ b/deploy/docker/fs/opt/appsmith/templates/supervisord/redis.conf @@ -8,7 +8,7 @@ autostart=true autorestart=true startsecs=0 startretries=3 -stdout_logfile=/appsmith-stacks/logs/%(program_name)s/%(program_name)s.log +stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/%(program_name)s.log redirect_stderr=true stdout_logfile_maxbytes=10MB stderr_logfile_maxbytes=10MB