Respect CONFIG_ENABLED_APPS in .env

This commit is contained in:
Bruno Bernardino
2024-05-01 09:21:30 +01:00
parent 635ca90de0
commit 6ee0a56f0c
8 changed files with 64 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
import { Cron } from 'https://deno.land/x/croner@8.0.1/dist/croner.js';
import { isAppEnabled } from '/lib/config.ts';
import { cleanupSessions } from './cleanup.ts';
import { fetchNewArticles } from './news.ts';
@@ -16,17 +17,19 @@ export function startCrons() {
},
);
new Cron(
// Every 30 minutes.
'*/30 * * * *',
{
name: 'news',
protect: true,
},
async () => {
await fetchNewArticles();
},
);
if (isAppEnabled('news')) {
new Cron(
// Every 30 minutes.
'*/30 * * * *',
{
name: 'news',
protect: true,
},
async () => {
await fetchNewArticles();
},
);
}
console.log('Crons starting...');
}