MCPcopy Create free account
hub / github.com/tiann/hapi / cleanup

Function cleanup

cli/src/agent/runnerLifecycle.ts:47–72  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

45 }
46
47 const cleanup = async () => {
48 if (cleanupPromise) {
49 return cleanupPromise
50 }
51
52 cleanupStarted = true
53 cleanupPromise = (async () => {
54 logger.debug(`${logPrefix} Cleanup start`)
55 restoreTerminalState()
56
57 try {
58 options.stopKeepAlive?.()
59 await options.onBeforeClose?.()
60 await archiveAndClose()
61 logger.debug(`${logPrefix} Cleanup complete`)
62 } finally {
63 try {
64 await options.onAfterClose?.()
65 } catch (error) {
66 logger.debug(`${logPrefix} Error during post-cleanup:`, error)
67 }
68 }
69 })()
70
71 return cleanupPromise
72 }
73
74 const cleanupAndExit = async (codeOverride?: number) => {
75 if (codeOverride !== undefined) {

Callers 3

cleanupAndExitFunction · 0.70
onConnectMethod · 0.50
waitForConnectedMethod · 0.50

Calls 4

restoreTerminalStateFunction · 0.90
archiveAndCloseFunction · 0.85
debugMethod · 0.80
stopKeepAliveMethod · 0.80

Tested by

no test coverage detected