MCPcopy
hub / github.com/vercel/next.js / shutdown

Function shutdown

bench/next-minimal-server/bin/minimal-server.js:41–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39
40let shuttingDown = false
41function shutdown() {
42 if (shuttingDown) return
43 shuttingDown = true
44
45 // Allow Node to exit cleanly so --cpu-prof/--heap-prof outputs are flushed.
46 server.close(() => {
47 process.exit(0)
48 })
49
50 // Fallback in case active keep-alive connections prevent close callback.
51 setTimeout(() => {
52 process.exit(1)
53 }, 5000).unref()
54}
55
56process.on('SIGTERM', shutdown)
57process.on('SIGINT', shutdown)

Callers 1

finalCallbackMethod · 0.50

Calls 4

unrefMethod · 0.80
closeMethod · 0.65
setTimeoutFunction · 0.50
exitMethod · 0.45

Tested by

no test coverage detected