index.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import * as cron from "node-cron";
  2. console.log("MovieDice cron service started");
  3. // Refresh landing reel posters — daily at 3:00 AM UTC
  4. cron.schedule("0 3 * * *", async () => {
  5. console.log(`[${new Date().toISOString()}] Reel refresh: starting`);
  6. // TODO: fetch trending movies from TMDB and update landing_reel_posters
  7. console.log(`[${new Date().toISOString()}] Reel refresh: complete`);
  8. });
  9. // Refresh trailer URLs — daily at 4:00 AM UTC
  10. cron.schedule("0 4 * * *", async () => {
  11. console.log(`[${new Date().toISOString()}] Trailer refresh: starting`);
  12. // TODO: re-validate trailer URLs for movies missing trailers
  13. console.log(`[${new Date().toISOString()}] Trailer refresh: complete`);
  14. });
  15. // Refresh TMDB metadata — monthly on the 1st at 5:00 AM UTC
  16. cron.schedule("0 5 1 * *", async () => {
  17. console.log(`[${new Date().toISOString()}] Metadata refresh: starting`);
  18. // TODO: refresh metadata for movies where metadata_refreshed_at > 30 days
  19. console.log(`[${new Date().toISOString()}] Metadata refresh: complete`);
  20. });
  21. // Keep the process alive
  22. process.on("SIGTERM", () => {
  23. console.log("Received SIGTERM, shutting down cron service");
  24. process.exit(0);
  25. });