stop

View as MarkdownOpen in Claude

Stop the HTTP server started by run() or serve(). Closes the underlying @hono/node-server instance and releases the port.

Unlike the Python counterpart (which only flips an internal flag), the TypeScript stop() actually closes the listener. It is safe to call when no server is running — it no-ops if the service hasn’t been started.

Returns

void

Example

1import { SWMLService } from '@signalwire/sdk';
2
3const service = new SWMLService({ name: 'my-service' });
4await service.run({ host: '0.0.0.0', port: 3000 });
5
6// In a signal handler or shutdown hook:
7process.on('SIGINT', () => {
8 service.stop();
9 process.exit(0);
10});