Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Remove R2 file cronjob

Edward Cuib243c0cc6f72
diff --git a/server/src/index.ts b/server/src/index.ts
index c1631ce89..2226f71eb 100644
--- a/server/src/index.ts
+++ b/server/src/index.ts
@@ -76,7 +76,6 @@ import { trackEvent } from "./services/tracker/trackEvent.js";
// need to import telemetry service here to start it
import { telemetryService } from "./services/telemetryService.js";
import { weeklyReportService } from "./services/weekyReports/weeklyReportService.js";
-import { importCleanupService } from "./services/import/importCleanupService.js";
import { extractSiteId } from "./utils.js";
import { getTrackingConfig } from "./api/sites/getTrackingConfig.js";
import { updateSitePrivateLinkConfig } from "./api/sites/updateSitePrivateLinkConfig.js";
@@ -483,11 +482,6 @@ const start = async () => {
// Don't exit - allow server to run without import features
}
- // Initialize import cleanup service (runs daily to clean up old import files)
- if (IS_CLOUD) {
- importCleanupService.initializeCleanupCron();
- }
-
// Start the server first
await server.listen({ port: 3001, host: "0.0.0.0" });
server.log.info("Server is listening on http://0.0.0.0:3001");
diff --git a/server/src/services/import/importCleanupService.ts b/server/src/services/import/importCleanupService.ts
deleted file mode 100644
index e61fb2b87..000000000
--- a/server/src/services/import/importCleanupService.ts
+++ /dev/null
@@ -1,64 +0,0 @@
-import * as cron from "node-cron";
-import { r2Storage } from "../storage/r2StorageService.js";
-import { createServiceLogger } from "../../lib/logger/logger.js";
-
-const logger = createServiceLogger("import:cleanup");
-
-class ImportCleanupService {
- private cleanupTask: cron.ScheduledTask | null = null;
-
- constructor() {}
-
- /**
- * Initialize the cleanup cron job.
- * Runs daily at 2 AM UTC to clean up orphaned import files.
- */
- initializeCleanupCron() {
- logger.info("Initializing cleanup cron");
-
- // Schedule cleanup to run daily at 2 AM UTC
- this.cleanupTask = cron.schedule(
- "0 2 * * *",
- async () => {
- try {
- await this.cleanupOrphanedFiles();
- } catch (error) {
- logger.error({ error }, "Error during cleanup");
- }
- },
- { timezone: "UTC" }
- );
-
- logger.info("Cleanup initialized (runs daily at 2 AM UTC)");
- }
-
- /**
- * Clean up orphaned R2 import files that are more than 1 day old.
- */
- private async cleanupOrphanedFiles() {
- if (r2Storage.isEnabled()) {
- logger.info("Starting cleanup of old R2 import files");
- try {
- const r2DeletedCount = await r2Storage.deleteOldImportFiles(1);
- logger.info({ deletedCount: r2DeletedCount }, "Deleted old files from R2");
- } catch (error) {
- logger.error({ error }, "Error cleaning up R2 files");
- }
- }
- }
-
- async triggerManualCleanup() {
- logger.info("Manual cleanup triggered");
- await this.cleanupOrphanedFiles();
- }
-
- stopCleanupCron() {
- if (this.cleanupTask) {
- this.cleanupTask.stop();
- logger.info("Cleanup cron stopped");
- }
- }
-}
-
-// Export singleton instance
-export const importCleanupService = new ImportCleanupService();
diff --git a/server/src/services/import/workers/csvParseWorker.ts b/server/src/services/import/workers/csvParseWorker.ts
index c16c6eaa3..8dcd50abf 100644
--- a/server/src/services/import/workers/csvParseWorker.ts
+++ b/server/src/services/import/workers/csvParseWorker.ts
@@ -215,7 +215,6 @@ export async function createCsvParseWorker(jobQueue: IJobQueue) {
} catch (deleteError) {
logger.warn({ importId, error: deleteError }, "File cleanup failed, will remain in storage");
// File will be orphaned but import status is already recorded
- // importCleanupService.ts handles orphans
}
}
});