Files
tts-server/examples/terminate.mjs
mikael-lovqvists-claude-agent 6357ff6a58 Add POST /command endpoint with terminate support (closes #2)
Sends {"status": "ok"} before shutting down so the caller gets a clean
response. Shutdown runs in a daemon thread to avoid deadlocking the
handler. Adds examples/terminate.mjs as a Node.js usage example.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-07 07:37:42 +00:00

17 lines
425 B
JavaScript

// Gracefully terminate the Chatterbox TTS server.
// Usage: node terminate.mjs
const PORT = process.env.TTS_PORT ?? '11500'
const res = await fetch(`http://localhost:${PORT}/command`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ command: 'terminate' }),
})
const data = await res.json()
if (data.status !== 'ok') {
console.error('error:', data.message)
process.exit(1)
}