Monorepo for wisp.place. A static site hosting service built on top of the AT Protocol. wisp.place
1import app from './server'; 2import { FirehoseWorker } from './lib/firehose'; 3import { logger } from './lib/observability'; 4import { mkdirSync, existsSync } from 'fs'; 5 6const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3001; 7const CACHE_DIR = './cache/sites'; 8 9// Ensure cache directory exists 10if (!existsSync(CACHE_DIR)) { 11 mkdirSync(CACHE_DIR, { recursive: true }); 12 console.log('Created cache directory:', CACHE_DIR); 13} 14 15// Start firehose worker with observability logger 16const firehose = new FirehoseWorker((msg, data) => { 17 logger.info(msg, data); 18}); 19 20firehose.start(); 21 22// Add health check endpoint 23app.get('/health', () => { 24 const firehoseHealth = firehose.getHealth(); 25 return { 26 status: 'ok', 27 firehose: firehoseHealth, 28 }; 29}); 30 31// Start HTTP server 32app.listen(PORT, () => { 33 console.log(` 34Wisp Hosting Service 35 36Server: http://localhost:${PORT} 37Health: http://localhost:${PORT}/health 38Cache: ${CACHE_DIR} 39Firehose: Connected to Firehose 40`); 41}); 42 43// Graceful shutdown 44process.on('SIGINT', async () => { 45 console.log('\n🛑 Shutting down...'); 46 firehose.stop(); 47 app.stop(); 48 process.exit(0); 49}); 50 51process.on('SIGTERM', async () => { 52 console.log('\n🛑 Shutting down...'); 53 firehose.stop(); 54 app.stop(); 55 process.exit(0); 56});