// Minimal launcher: boot keet-daemon against a storage + socket, stay alive.
// bare tools/run-daemon.mjs --storage <root> --sock <path> [--secs N]
import { startDaemon } from '../index.js'
const a = Bare.argv.slice(2); const gi = f => { const i = a.indexOf(f); return i>=0?a[i+1]:null }
const storage = gi('--storage'); const sock = gi('--sock') || '/tmp/keet-daemon.sock'; const secs = Number(gi('--secs')||120)
const d = await startDaemon({ storage, socketPath: sock, pidFile: sock + '.pid', debug: false })
await d.core.backendAPI.ready()
console.log('[run-daemon] ready sock=' + sock)
setTimeout(() => { console.log('[run-daemon] exiting'); Bare.exit(0) }, secs*1000)