refactor(worker): use native bun cron
This commit is contained in:
+1
-2
@@ -36,5 +36,4 @@ CMD ["bun", "start"]
|
|||||||
# Stage 4: Scheduled video upload worker
|
# Stage 4: Scheduled video upload worker
|
||||||
FROM deps AS video-upload-worker
|
FROM deps AS video-upload-worker
|
||||||
COPY . .
|
COPY . .
|
||||||
COPY scripts/video-upload-crontab /etc/crontabs/root
|
CMD ["bun", "run", "worker/video-upload.ts"]
|
||||||
ENTRYPOINT ["crond", "-f", "-l", "2", "-L", "/dev/stdout"]
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
* * * * * bun run /app/worker/video-upload.ts
|
|
||||||
+15
-7
@@ -1,11 +1,19 @@
|
|||||||
import { processDueVideoUploads } from "@/lib/video/video-platforms";
|
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 {
|
try {
|
||||||
await processDueVideoUploads();
|
await processDueVideoUploads();
|
||||||
console.log(`[${new Date().toISOString()}] Scheduled video upload check finished.`);
|
console.log(
|
||||||
} catch (error) {
|
`[${new Date().toISOString()}] Scheduled video upload check finished.`,
|
||||||
console.error("Scheduled video upload worker failed:", error);
|
);
|
||||||
process.exitCode = 1;
|
} 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.");
|
||||||
|
|||||||
Reference in New Issue
Block a user