feat: add daemon skeleton with lifecycle management
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+30
-1
@@ -1 +1,30 @@
|
||||
console.log('Flynn starting...');
|
||||
import { loadConfig } from './config/index.js';
|
||||
import { startDaemon } from './daemon/index.js';
|
||||
import { resolve } from 'path';
|
||||
import { homedir } from 'os';
|
||||
|
||||
const CONFIG_PATH = process.env.FLYNN_CONFIG
|
||||
?? resolve(homedir(), '.config/flynn/config.yaml');
|
||||
|
||||
async function main() {
|
||||
console.log('Flynn starting...');
|
||||
console.log(`Loading config from: ${CONFIG_PATH}`);
|
||||
|
||||
try {
|
||||
const config = loadConfig(CONFIG_PATH);
|
||||
const daemon = await startDaemon(config);
|
||||
|
||||
console.log(`Telegram bot configured for chat IDs: ${config.telegram.allowed_chat_ids.join(', ')}`);
|
||||
console.log(`Server port: ${config.server.port}`);
|
||||
|
||||
// Keep process alive
|
||||
await new Promise<void>((resolve) => {
|
||||
daemon.lifecycle.onShutdown(async () => resolve());
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Failed to start Flynn:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user