Replace generated archive download response with FileResponse streaming so ZIP files are not fully loaded into process memory. Move monthly archive task output to a temporary file and upload that file to storage, and write invoice attachments into ZIP archives in chunks. Add Celery memory guard settings, a memory-aware base task hook, and periodic /tmp cleanup for prefixed archive files older than one day. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
25 lines
606 B
Bash
25 lines
606 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
TMP_DIR="${APP_TMP_CLEANUP_DIR:-/tmp}"
|
|
MAX_AGE_DAYS="${APP_TMP_CLEANUP_MAX_AGE_DAYS:-1}"
|
|
PREFIXES="${APP_TMP_CLEANUP_PREFIXES:-erp-fleet-archive-}"
|
|
|
|
if [ ! -d "$TMP_DIR" ]; then
|
|
echo "TMP dir ne postoji: $TMP_DIR"
|
|
exit 0
|
|
fi
|
|
|
|
OLD_IFS="$IFS"
|
|
IFS=','
|
|
for prefix in $PREFIXES; do
|
|
prefix_trimmed="$(echo "$prefix" | xargs)"
|
|
if [ -z "$prefix_trimmed" ]; then
|
|
continue
|
|
fi
|
|
find "$TMP_DIR" -maxdepth 1 -mindepth 1 -name "${prefix_trimmed}*" -mtime "+${MAX_AGE_DAYS}" -print -delete
|
|
done
|
|
IFS="$OLD_IFS"
|
|
|
|
echo "TMP cleanup dovršen za $TMP_DIR (older than ${MAX_AGE_DAYS} day(s))."
|