updated runtime to allow environment variable setting and defaulted to 5 minutes

master
j 2024-03-23 13:47:10 -04:00
parent 9863078fd9
commit 3c117abbd3
1 changed files with 11 additions and 2 deletions

View File

@ -5,7 +5,8 @@ import rDramaSession from './rdrama/session/SessionManager';
import RedisSessionManager from './redis/session/SessionManager';
import { CommentProcessor } from './rdrama/services/CommentProcessor';
const workflowInterval = 60000; // Run every 60,000 milliseconds (1 minute)
// Run every 300,000 milliseconds (5 minutes) by default
const workflowInterval = 1000 * 60 * Number(process.env.POLLING_FREQUENCY || 5);
async function startApplication() {
console.log('Redis Start');
@ -18,7 +19,15 @@ async function startApplication() {
}
rDramaSessionManager.setAuthorizationToken(process.env.RDRAMA_API_KEY);
// Initialize and start your workflow
// Initialize and start workflow
try {
await CommentProcessor.processComments();
console.log('Workflow executed successfully.');
} catch (error) {
console.error('An error occurred during workflow execution:', error);
}
// Schedule future runs
setInterval(async () => {
try {
await CommentProcessor.processComments();