diff --git a/.env.example b/.env.example index 1e6f15bff4..3e75b72994 100644 --- a/.env.example +++ b/.env.example @@ -85,6 +85,8 @@ OPENAI_API_KEY="" NEXT_PUBLIC_DISCORD_SUPPORT="" NEXT_PUBLIC_POLOTNO="" # NOT_SECURED=false + +# POSTIZ_ACTIVE_PROVIDERS= API_LIMIT=30 # The limit of the public API hour limit # When connecting providers that take a self-hosted URL (WordPress, Mastodon, diff --git a/libraries/nestjs-libraries/src/temporal/temporal.module.ts b/libraries/nestjs-libraries/src/temporal/temporal.module.ts index 85c54bfd8a..ad3790992b 100644 --- a/libraries/nestjs-libraries/src/temporal/temporal.module.ts +++ b/libraries/nestjs-libraries/src/temporal/temporal.module.ts @@ -1,6 +1,14 @@ import { TemporalModule } from 'nestjs-temporal-core'; import { socialIntegrationList } from '@gitroom/nestjs-libraries/integrations/integration.manager'; +function parseActiveProviders(): Set | null { + const raw = process.env.POSTIZ_ACTIVE_PROVIDERS; + if (!raw || !raw.trim()) return null; + return new Set( + raw.split(',').map((p) => p.trim().toLowerCase()).filter(Boolean) + ); +} + export const getTemporalModule = ( isWorkers: boolean, path?: string, @@ -23,6 +31,10 @@ export const getTemporalModule = ( Number(process.env.WORKER_CONCURRENCY_DIVIDER) || 1 ); + // Providers this server should run workers for (comma-separated). + // Unset => all providers (backwards-compatible default). + const activeProviders = parseActiveProviders(); + return TemporalModule.register({ isGlobal: true, connection: { @@ -46,7 +58,13 @@ export const getTemporalModule = ( integration, taskQueue: integration.identifier.split('-')[0], })) - .filter(({ taskQueue }) => !excludeQueues.includes(taskQueue)) + .filter( + ({ taskQueue }) => + !excludeQueues.includes(taskQueue) && + (taskQueue === 'main' || + activeProviders === null || + activeProviders.has(taskQueue)) + ) .map(({ integration, taskQueue }) => { // Split the per-provider cap across the servers sharing this // queue. Floor (never below 1) so the global total never exceeds