MCPcopy
hub / github.com/xpf0000/FlyEnv / stopHttpServer

Function stopHttpServer

src/shared/httpServerStop.ts:7–31  ·  view source on GitHub ↗
(
  server?: HttpServer,
  closeables?: Iterable<HttpServerCloseable>
)

Source from the content-addressed store, hash-verified

5}
6
7export async function stopHttpServer(
8 server?: HttpServer,
9 closeables?: Iterable<HttpServerCloseable>
10): Promise<void> {
11 if (closeables) {
12 await Promise.allSettled(
13 Array.from(closeables, (item) => Promise.resolve().then(() => item.close()))
14 )
15 }
16
17 if (!server) {
18 return
19 }
20
21 await new Promise<void>((resolve, reject) => {
22 server.close((error) => {
23 if (error) {
24 reject(error)
25 return
26 }
27 resolve()
28 })
29 server.closeAllConnections?.()
30 })
31}

Callers 1

stopMethod · 0.90

Calls 4

resolveFunction · 0.85
resolveMethod · 0.80
thenMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected