Files
bewcloud/crons/index.ts
2024-04-17 14:01:06 +01:00

33 lines
586 B
TypeScript

import { Cron } from 'https://deno.land/x/croner@8.0.1/dist/croner.js';
import { cleanupSessions } from './cleanup.ts';
import { fetchNewArticles } from './news.ts';
export function startCrons() {
new Cron(
// At 03:06 every day.
'6 3 * * *',
{
name: 'cleanup',
protect: true,
},
async () => {
await cleanupSessions();
},
);
new Cron(
// Every 30 minutes.
'*/30 * * * *',
{
name: 'news',
protect: true,
},
async () => {
await fetchNewArticles();
},
);
console.log('Crons starting...');
}