feat: add ability to change application logs location (#31926)
Fixes [31877](https://github.com/appsmithorg/appsmith/issues/31877) ``` sudo docker run -it -d --name ap -e APPSMITH_LOG_DIR=/logs --pull always appsmith/appsmith-dp:ce-31926 (base) ➜ appsmith-ee git:(release) ✗ docker exec -it -u root ap bash root@3d17510be0d7:/opt/appsmith# ls /logs/* /logs/backend: backend-3d17510be0d7.log /logs/editor: access-3d17510be0d7.log error-3d17510be0d7.log /logs/rts: rts-3d17510be0d7.log root@3d17510be0d7:/opt/appsmith# ```
This commit is contained in:
parent
0b3a2d298b
commit
d3acb4ba8f
|
|
@ -24,7 +24,7 @@ public class CleanUpOldLogs {
|
||||||
|
|
||||||
final long cutoffTime = System.currentTimeMillis() - CUTOFF_AGE;
|
final long cutoffTime = System.currentTimeMillis() - CUTOFF_AGE;
|
||||||
|
|
||||||
try (Stream<Path> walk = Files.walk(Paths.get("/appsmith-stacks/logs"))) {
|
try (Stream<Path> walk = Files.walk(Paths.get(System.getenv("APPSMITH_LOG_DIR")))) {
|
||||||
walk.filter(path -> {
|
walk.filter(path -> {
|
||||||
try {
|
try {
|
||||||
return Files.isRegularFile(path)
|
return Files.isRegularFile(path)
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ username=%(ENV_APPSMITH_SUPERVISOR_USER)s
|
||||||
password=%(ENV_APPSMITH_SUPERVISOR_PASSWORD)s
|
password=%(ENV_APPSMITH_SUPERVISOR_PASSWORD)s
|
||||||
|
|
||||||
[supervisord]
|
[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)
|
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
|
stdout_logfile_maxbytes = 0
|
||||||
stderr_logfile_maxbytes = 0
|
stderr_logfile_maxbytes = 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -454,7 +454,7 @@ function setup_auto_heal(){
|
||||||
if [[ ${APPSMITH_AUTO_HEAL-} = 1 ]]; then
|
if [[ ${APPSMITH_AUTO_HEAL-} = 1 ]]; then
|
||||||
# By default APPSMITH_AUTO_HEAL=0
|
# By default APPSMITH_AUTO_HEAL=0
|
||||||
# To enable auto heal set APPSMITH_AUTO_HEAL=1
|
# 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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -490,7 +490,8 @@ configure_supervisord
|
||||||
mkdir -p /appsmith-stacks/data/{backup,restore} /appsmith-stacks/ssl
|
mkdir -p /appsmith-stacks/data/{backup,restore} /appsmith-stacks/ssl
|
||||||
|
|
||||||
# Create sub-directory to store services log in the container mounting folder
|
# 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
|
setup_auto_heal
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import atexit
|
import atexit
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import shutil
|
import os.path
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
import urllib.error
|
import urllib.error
|
||||||
|
|
@ -10,7 +10,7 @@ import urllib.request
|
||||||
|
|
||||||
LOADING_PAGE_EDITOR = os.getenv("WWW_PATH") + '/loading.html'
|
LOADING_PAGE_EDITOR = os.getenv("WWW_PATH") + '/loading.html'
|
||||||
BACKEND_HEALTH_ENDPOINT = "http://localhost:8080/api/v1/health"
|
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'
|
LOG_FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||||
|
|
||||||
logging.basicConfig(filename = LOG_FILE, level = logging.NOTSET, format = LOG_FORMAT)
|
logging.basicConfig(filename = LOG_FILE, level = logging.NOTSET, format = LOG_FORMAT)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startsecs=20
|
startsecs=20
|
||||||
startretries=3
|
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
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startsecs=0
|
startsecs=0
|
||||||
startretries=3
|
startretries=3
|
||||||
stdout_logfile=/appsmith-stacks/logs/%(program_name)s/access-%(ENV_HOSTNAME)s.log
|
stdout_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/access-%(ENV_HOSTNAME)s.log
|
||||||
stderr_logfile=/appsmith-stacks/logs/%(program_name)s/error-%(ENV_HOSTNAME)s.log
|
stderr_logfile=%(ENV_APPSMITH_LOG_DIR)s/%(program_name)s/error-%(ENV_HOSTNAME)s.log
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
stdout_logfile_backups=2
|
stdout_logfile_backups=2
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startsecs=0
|
startsecs=0
|
||||||
startretries=3
|
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
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
[program:mongodb]
|
[program:mongodb]
|
||||||
directory=/appsmith-stacks/data/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
|
priority=10
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startsecs=10
|
startsecs=10
|
||||||
startretries=3
|
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
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ command=/opt/appsmith/run-postgres.sh
|
||||||
autostart=true
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startretries=3
|
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
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startsecs=0
|
startsecs=0
|
||||||
startretries=3
|
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
|
redirect_stderr=true
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
stderr_logfile_maxbytes=10MB
|
stderr_logfile_maxbytes=10MB
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user