-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete exports and files after expire time (#213)
* added cron jobs to delete old files and exports * moved cleanup retention days arg to application yml --------- Co-authored-by: Yuan Chen <[email protected]>
- Loading branch information
1 parent
06a3067
commit 14d4757
Showing
12 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ RABBIT_PORT=5672 | |
|
||
PROMETHEUS_PORT=9090 | ||
GRAFANA_PORT=3000 | ||
|
||
FILES_RETENTION_DAYS= | ||
EXPORTS_RETENTION_DAYS= |
This file contains 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
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/dk/cachet/carp/webservices/export/scheduler/ExportCleanup.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dk.cachet.carp.webservices.export.scheduler | ||
|
||
import dk.cachet.carp.webservices.export.service.ExportService | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class ExportCleanup( | ||
private val exportService: ExportService, | ||
@Value("\${cleanup.exports.retention-days}") private val days: Int, | ||
) { | ||
companion object { | ||
private val LOGGER: Logger = LogManager.getLogger() | ||
} | ||
|
||
@Scheduled(cron = "0 5 9 * * ?") | ||
fun cleanup() { | ||
LOGGER.info("Cleaning up exports...") | ||
exportService.deleteAllOlderThan(days) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,6 @@ interface ExportService { | |
studyId: UUID, | ||
exportId: UUID, | ||
): UUID | ||
|
||
fun deleteAllOlderThan(days: Int) | ||
} |
This file contains 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
This file contains 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
24 changes: 24 additions & 0 deletions
24
src/main/kotlin/dk/cachet/carp/webservices/file/scheduler/FileCleanup.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package dk.cachet.carp.webservices.file.scheduler | ||
|
||
import dk.cachet.carp.webservices.file.service.FileService | ||
import org.apache.logging.log4j.LogManager | ||
import org.apache.logging.log4j.Logger | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.scheduling.annotation.Scheduled | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class FileCleanup( | ||
private val fileService: FileService, | ||
@Value("\${cleanup.files.retention-days}") private val days: Int, | ||
) { | ||
companion object { | ||
private val LOGGER: Logger = LogManager.getLogger() | ||
} | ||
|
||
@Scheduled(cron = "0 0 9 * * ?") | ||
fun cleanup() { | ||
LOGGER.info("Cleaning up files...") | ||
fileService.deleteAllOlderThan(days) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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