Skip to content

Commit

Permalink
update ErrorFile path to /files for persistence; purge 90+ day old he…
Browse files Browse the repository at this point in the history
…ap/error dirs
  • Loading branch information
labkey-willm committed Jan 10, 2025
1 parent 721e5ac commit 3568c4e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ services:
- JSON_OUTPUT=${JSON_OUTPUT-false}
- DD_COLLECT_APM=${DD_COLLECT_APM-false}
- SLEEP=${SLEEP:-0}
- PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS=${PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS:-90}

pg-lims_starter:
image: postgres:15
Expand Down
16 changes: 12 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ CSP_ENFORCE="${CSP_ENFORCE:-}"
DD_COLLECT_APM="${DD_COLLECT_APM:-false}"
JAVA_RMI_SERVER_HOSTNAME="${JAVA_RMI_SERVER_HOSTNAME:-}"

# set age past which old heap and error log directories are removed
PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS="${PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS:-90}"

SLEEP="${SLEEP:=0}"

main() {
Expand Down Expand Up @@ -263,22 +266,27 @@ main() {
unset LABKEY_CREATE_INITIAL_USER LABKEY_CREATE_INITIAL_USER_APIKEY LABKEY_INITIAL_USER_APIKEY LABKEY_INITIAL_USER_EMAIL LABKEY_INITIAL_USER_GROUP LABKEY_INITIAL_USER_ROLE
unset LABKEY_EK SLEEP CONTAINER_PRIVATE_IP

HEAP_DUMP_PATH="$LABKEY_HOME/files/heap_dumps_$(date +%Y%m%d_%H%M%S)"
mkdir -pv $HEAP_DUMP_PATH
echo "Creating new heap/error log directory..."
HEAP_AND_ERROR_PATH="$LABKEY_HOME/files/heap_dumps_and_errors_$(date +%Y%m%d_%H%M%S)"
mkdir -pv $HEAP_AND_ERROR_PATH

# purge old heap/error directories
echo "Purging heap/error log directories older than $PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS days..."
find "$LABKEY_HOME/files/" -mindepth 1 -maxdepth 1 -type d -ctime +${PURGE_HEAP_AND_ERROR_LOGS_OLDER_THAN_DAYS} -name "heap*" | xargs rm -rf

# shellcheck disable=SC2086
exec java \
\
-Duser.timezone="${JAVA_TIMEZONE}" \
\
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath="${HEAP_DUMP_PATH}" \
-XX:HeapDumpPath="${HEAP_AND_ERROR_PATH}" \
\
-XX:MaxRAMPercentage="${MAX_JVM_RAM_PERCENT}" \
\
-XX:+UseContainerSupport \
\
-XX:ErrorFile="${LABKEY_HOME}/logs/error_%p.log" \
-XX:ErrorFile="${HEAP_AND_ERROR_PATH}/error_%p.log" \
\
-Djava.net.preferIPv4Stack=true \
\
Expand Down

0 comments on commit 3568c4e

Please sign in to comment.