Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ ENCRYPTION_KEY=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/openreply
REDIS_URL=redis://localhost:6379

# Backup scan for comments missed by Meta webhooks (15 minutes)
COMMENT_POLL_INTERVAL_MS=900000

# Email magic links (Resend)
RESEND_API_KEY=re_...
EMAIL_FROM=OpenReply <login@example.com>
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Optional, for tuning the polling reconciler (defaults are fine to start):

| Variable | Default | What it does |
| --- | --- | --- |
| `COMMENT_POLL_INTERVAL_MS` | `300000` | How often the worker sweeps for missed comments (5 min). |
| `COMMENT_POLL_INTERVAL_MS` | `900000` | How often the worker sweeps for missed comments (15 min). Keep this above your database autosuspend delay. |
| `COMMENT_POLL_MAX_PER_SWEEP` | `30` | Max new comments each campaign acts on per sweep. Keep it conservative; higher gets closer to Instagram's rate limits. |
| `COMMENT_POLL_LOOKBACK_HOURS` | `72` | How far back a sweep considers comments. |

Expand Down
6 changes: 3 additions & 3 deletions worker/dm-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import os from "node:os";
const worker = createDMWorker();
const startedAt = new Date().toISOString();
const HEARTBEAT_INTERVAL_MS = 30_000;
// Polling safety net for comments that webhooks miss. Runs in the worker because
// it must fire every few minutes and Vercel's free crons only run once a day.
// Polling safety net for comments that webhooks miss. Keep this longer than
// Neon's five-minute autosuspend delay so an idle database can scale to zero.
const POLL_INTERVAL_MS = Number(
process.env.COMMENT_POLL_INTERVAL_MS ?? 5 * 60_000
process.env.COMMENT_POLL_INTERVAL_MS ?? 15 * 60_000
);

console.log("[DM Worker] Started");
Expand Down