#!/usr/bin/env node import { loadConfig } from './config.js' import { startServer } from './server.js' const configPath = process.argv[2] if (!configPath) { console.error('usage: keyhole ') process.exit(2) } try { const config = await loadConfig(configPath) const server = await startServer(config) const address = server.address() if (!address || typeof address === 'string') throw new Error('server address unavailable') console.error(`keyhole listening on http://${address.address}:${address.port}`) const shutdown = () => server.close(() => process.exit(0)) process.on('SIGINT', shutdown) process.on('SIGTERM', shutdown) } catch { console.error('keyhole failed to start') process.exit(1) }