dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
860 stars 468 forks source link

Simplify cleanup jobs #25677

Open wezell opened 1 year ago

wezell commented 1 year ago

Parent Issue

No response

Problem Statement

We have a number of "cleanup" jobs that should take care of cleaning up old tmp files, backups and bundles. They should be consolidated into 1 job so we can understand what is happening.

Steps to Reproduce

n /a

Acceptance Criteria

Have one job that cleans up tmp files and old bundles.

dotCMS Version

23.07

Proposed Objective

Cloud Engineering

Proposed Priority

Priority 2 - Important

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

No response

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

jdotcms commented 1 year ago

nice; I think one Job can be fired every minute and it can encapsulate a set of strategies (with the time schedule) so if it is the time to run the delegate, then it is fired

such as CleanUpStrategy {

boolean test(Date date); void apply(Object context): }

jcastro-dotcms commented 1 year ago

NOTE TO DOC

Information on what the BinaryCleanupJob does and how it can be configured can be found in the class' Javadoc section here: https://github.com/dotCMS/core/pull/25902/files#diff-8b7f7a7c66b554cb35709aa413b116823de499d47ab3a3953ebe7709a0b3be6d

jcastro-dotcms commented 1 year ago

NOTE TO QA

Here's the list of steps you can follow in order to verify the correct behavior of the Binary Cleanup Job:

  1. Set the following configuration properties in the docker-compose.yml file. In this case, set the Job to run every two minutes, and clean up ALL temporary files:
    DOT_BINARY_CLEANUP_JOB_CRON_EXPRESSION: '0 0/2 * 1/1 * ? *'
    DOT_CLEANUP_TMP_FILES_OLDER_THAN_HOURS: 0
  2. Start up dotCMS.
  3. Upload some test File Assets so that internal temp files are generated.
  4. Wait for about two minutes and you should see the following message in the dotcms.log file:
    15:12:00.088  INFO  job.BinaryCleanupJob - STARTING TMP/TRASH FILE CLEANUP
    15:12:54.425  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /Users/jcastro-2022/dotCMS/git/dev/main-master/dotcms_assets/assets/tmp_upload
    15:12:54.429  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /Users/jcastro-2022/dotCMS/git/dev/main-master/dotcms_assets/dotsecure/trash
    15:12:54.429  INFO  util.FileUtil - cleanTree Directory /Users/jcastro-2022/dotCMS/git/dev/main-master/dotcms_assets/dotsecure/trash not found exiting
    15:12:54.429  INFO  job.BinaryCleanupJob - Deleting files older than 3 days from /Users/jcastro-2022/dotCMS/git/dev/main-master/dotcms_assets/dotsecure/backup
    15:12:54.429  INFO  util.FileUtil - cleanTree Directory /Users/jcastro-2022/dotCMS/git/dev/main-master/dotcms_assets/dotsecure/backup not found exiting
    15:12:54.429  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /Users/jcastro-2022/dotCMS/git/dev/main-master/tomcat9/temp
    15:12:54.430  INFO  job.BinaryCleanupJob - ENDING TMP/TRASH FILE CLEANUP
fmontes commented 1 year ago

Working for me:

test-dotcms-1         | 21:12:00.024  INFO  job.BinaryCleanupJob - STARTING TMP/TRASH FILE CLEANUP
test-dotcms-1         | 21:12:00.025  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /data/shared/assets/tmp_upload
test-dotcms-1         | 21:12:00.038  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /data/local/dotsecure/trash
test-dotcms-1         | 21:12:00.044  INFO  job.BinaryCleanupJob - Deleting files older than 3 days from /data/local/dotsecure/backup
test-dotcms-1         | 21:12:00.045  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /srv/dotserver/tomcat/temp
test-dotcms-1         | 21:12:00.046  INFO  job.BinaryCleanupJob - ENDING TMP/TRASH FILE CLEANUP
test-dotcms-1         | 21:15:00.016  INFO  job.BinaryCleanupJob - STARTING TMP/TRASH FILE CLEANUP
test-dotcms-1         | 21:15:00.016  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /data/shared/assets/tmp_upload
test-dotcms-1         | 21:15:00.017  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /data/local/dotsecure/trash
test-dotcms-1         | 21:15:00.018  INFO  job.BinaryCleanupJob - Deleting files older than 3 days from /data/local/dotsecure/backup
test-dotcms-1         | 21:15:00.018  INFO  job.BinaryCleanupJob - Deleting files older than 0 hours from /srv/dotserver/tomcat/temp
test-dotcms-1         | 21:15:00.018  INFO  job.BinaryCleanupJob - ENDING TMP/TRASH FILE CLEANUP