refactor(worker): use native bun cron

This commit is contained in:
2026-08-02 19:12:58 +07:00 Unverified
parent a43e99aa10
commit 353cc0528c
3 changed files with 16 additions and 10 deletions
+1 -2
View File
@@ -36,5 +36,4 @@ CMD ["bun", "start"]
# Stage 4: Scheduled video upload worker
FROM deps AS video-upload-worker
COPY . .
COPY scripts/video-upload-crontab /etc/crontabs/root
ENTRYPOINT ["crond", "-f", "-l", "2", "-L", "/dev/stdout"]
CMD ["bun", "run", "worker/video-upload.ts"]
-1
View File
@@ -1 +0,0 @@
* * * * * bun run /app/worker/video-upload.ts
+15 -7
View File
@@ -1,11 +1,19 @@
import { processDueVideoUploads } from "@/lib/video/video-platforms";
console.log(`[${new Date().toISOString()}] Checking scheduled video uploads.`);
async function processScheduledUploads() {
console.log(`[${new Date().toISOString()}] Checking scheduled video uploads.`);
try {
await processDueVideoUploads();
console.log(`[${new Date().toISOString()}] Scheduled video upload check finished.`);
} catch (error) {
console.error("Scheduled video upload worker failed:", error);
process.exitCode = 1;
try {
await processDueVideoUploads();
console.log(
`[${new Date().toISOString()}] Scheduled video upload check finished.`,
);
} catch (error) {
console.error("Scheduled video upload worker failed:", error);
}
}
await processScheduledUploads();
Bun.cron("* * * * *", processScheduledUploads);
console.log("Video upload worker scheduled every minute with Bun.cron.");