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>
17 lines
425 B
JavaScript
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)
|
|
}
|