feat: Scheduled Cleanup of Build Logs for all Deployments - #66
Open
alronova wants to merge 2 commits into
Open
Conversation
- truncate log files for those exceeding 500kb file size - cleanup of `.log` & `.status` files for subdomains that don't exist on the DB (failed deployments) Signed-off-by: alronova <aditya.divyam001@gmail.com>
Signed-off-by: alronova <aditya.divyam001@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat: Scheduled Log Cleanup for Build Logs
Problem
Build logs introduced in #63 are written via
tee -aincontainer.shandautomate.sh, causing{subdomain}.logfiles to grow indefinitely across deployments and CI/CD redeployments.This leads to:
.logand.statusfiles behind indefinitely.Solution
Added a scheduled cleanup module (
log-cleanup.ts) that runs every 24 hours (following the existinghealth-monitor.tsscheduler pattern) and performs two cleanup strategies.1. Log Truncation
For each active subdomain log in
/hostpipe/logs/:Implementation:
file_size - 500KB.This preserves recent deployment history while preventing unlimited growth. The existing
getLogsAPI continues to serve the last 100KB viareadLastNBytes(), while 500KB provides additional debugging context between cleanup cycles.2. Orphan Cleanup
For every
.logand.statusfile in/hostpipe/logs/and/hostpipe/status/:This removes artifacts left behind by incomplete deletions. Orphan removals are reported to Sentry for visibility and auditing.
Scheduler Behavior
setTimeout)setInterval)try/catchChecklist