From 3c117abbd368c7a4576db3ca1e732b588baa614a Mon Sep 17 00:00:00 2001 From: j Date: Sat, 23 Mar 2024 13:47:10 -0400 Subject: [PATCH] updated runtime to allow environment variable setting and defaulted to 5 minutes --- src/index.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index e7cfbbe..4deeea4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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();