This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: refactor process handling for in-memory and distributed event systems

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+19 -15
+1
fly.development.toml
··· 31 31 BASE_URL="https://api.dev.semble.so" 32 32 HOST="0.0.0.0" 33 33 APP_URL="https://dev.semble.so" 34 + USE_IN_MEMORY_EVENTS="false"
+1
fly.production.toml
··· 32 32 BASE_URL="https://api.semble.so" 33 33 HOST="0.0.0.0" 34 34 APP_URL="https://semble.so" 35 + USE_IN_MEMORY_EVENTS="false"
+2
scripts/dev-combined.sh
··· 15 15 # Trap SIGINT and SIGTERM to cleanup on exit 16 16 trap cleanup_and_exit SIGINT SIGTERM 17 17 18 + echo "Starting development with separate processes (BullMQ + Redis)..." 19 + 18 20 # Run both services with concurrently 19 21 concurrently -k -n APP,WORKER -c blue,green \ 20 22 "dotenv -e .env.local -- concurrently -k -n TYPE,APP -c red,blue \"tsc --noEmit --watch\" \"tsup --watch --onSuccess='node dist/index.js'\"" \
+2 -4
src/index.ts
··· 9 9 // Start the app process 10 10 await appProcess.start(); 11 11 12 - // Start appropriate worker based on event system type 12 + // Only start event worker in same process when using in-memory events 13 13 const useInMemoryEvents = process.env.USE_IN_MEMORY_EVENTS === 'true'; 14 14 if (useInMemoryEvents) { 15 15 console.log('Starting in-memory event worker in the same process...'); 16 16 const inMemoryWorkerProcess = new InMemoryEventWorkerProcess(configService); 17 17 await inMemoryWorkerProcess.start(); 18 18 } else { 19 - console.log('Starting BullMQ feed worker in the same process...'); 20 - const feedWorkerProcess = new FeedWorkerProcess(configService); 21 - await feedWorkerProcess.start(); 19 + console.log('Using external worker processes for event handling'); 22 20 } 23 21 } 24 22
+13 -11
src/workers/feed-worker.ts
··· 2 2 import { FeedWorkerProcess } from '../shared/infrastructure/processes/FeedWorkerProcess'; 3 3 4 4 async function main() { 5 + const useInMemoryEvents = process.env.USE_IN_MEMORY_EVENTS === 'true'; 6 + 7 + if (useInMemoryEvents) { 8 + console.log('Skipping feed worker startup - using in-memory events (handled by main process)'); 9 + return; 10 + } 11 + 12 + console.log('Starting dedicated feed worker process...'); 5 13 const configService = new EnvironmentConfigService(); 6 14 const feedWorkerProcess = new FeedWorkerProcess(configService); 7 - 15 + 8 16 await feedWorkerProcess.start(); 9 17 } 10 18 11 - if (process.env.USE_IN_MEMORY_EVENTS !== 'true') { 12 - main().catch((error) => { 13 - console.error('Failed to start feed worker:', error); 14 - process.exit(1); 15 - }); 16 - } else { 17 - console.log( 18 - 'Skipping feed worker startup - using in-memory events (worker runs inside main process)', 19 - ); 20 - } 19 + main().catch((error) => { 20 + console.error('Failed to start feed worker:', error); 21 + process.exit(1); 22 + });