diff options
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..f184d13 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,35 @@ +import { addTask, getTask } from "./tasks"; +import { runDownloadInstagramTask } from "./instagram_task"; +import { runWithRetries, wait } from "./utils"; + +// TESTING DATA +addTask({ + type: "download_instagram", + url: "https://www.instagram.com/reel/C33u39RBF5p/?igsh=MXZuZ2drN2wya2JmZg==", + replyId: "123", +}); + +(async () => { + const MAX_RETRIES = 5; + // Main loop + while (true) { + const task = getTask(); + if (task) { + try { + await runWithRetries(async () => { + if (task.type === "download_instagram") { + await runDownloadInstagramTask(task); + } else if (task.type === "slack_reply") { + console.log("TODO slack reply task"); + } else { + console.log("Unknown task type, skipping", task); + } + }, MAX_RETRIES); + } catch (e) { + console.error("Task failed after max retries, skipping task.", task, e); + } + } else { + await wait(1000); + } + } +})(); |
