# Readiness first, then bounded shutdown

> Documentation for Redweb 0.13.2. Install that exact version when following these examples.

Stop placement to the node, flip readiness, let cooperative handlers observe cancellation, and await deterministic cleanup.

This pattern demonstrates one API area. Application-specific names, credentials, assets, and policies may need to be supplied. Complete starter recipes include all required application files.

```js
const { HttpServer, SocketServer } = require('redweb')

const http = new HttpServer({ listen: false })
const socketServer = new SocketServer({
  server: http.server,
  routes: [MatchRoute],
})

http.app.get('/ready', (_request, response) => {
  response.sendStatus(socketServer.isReady() ? 200 : 503)
})

http.server.listen(3000)

process.once('SIGTERM', async () => {
  socketServer.beginDrain()
  await stopExternalPlacement()
  await socketServer.shutdown()
  await http.shutdown()
})

// In a handler with drainHandlers: true
await saveCheckpoint({ signal: socket.context.signal })
```

## Notes and boundaries

- New upgrades receive 503 once draining starts.
- The route signal is shared through socket.context.signal.
- A hard deadline terminates non-cooperating peers.
