(input)
| 81 | } |
| 82 | |
| 83 | async function handleSessionEnd(input) { |
| 84 | const cwd = input.cwd || process.cwd(); |
| 85 | const brokerSession = |
| 86 | loadBrokerSession(cwd) ?? |
| 87 | (process.env[BROKER_ENDPOINT_ENV] |
| 88 | ? { |
| 89 | endpoint: process.env[BROKER_ENDPOINT_ENV], |
| 90 | pidFile: process.env[PID_FILE_ENV] ?? null, |
| 91 | logFile: process.env[LOG_FILE_ENV] ?? null |
| 92 | } |
| 93 | : null); |
| 94 | const brokerEndpoint = brokerSession?.endpoint ?? null; |
| 95 | const pidFile = brokerSession?.pidFile ?? null; |
| 96 | const logFile = brokerSession?.logFile ?? null; |
| 97 | const sessionDir = brokerSession?.sessionDir ?? null; |
| 98 | const pid = brokerSession?.pid ?? null; |
| 99 | |
| 100 | if (brokerEndpoint) { |
| 101 | await sendBrokerShutdown(brokerEndpoint); |
| 102 | } |
| 103 | |
| 104 | cleanupSessionJobs(cwd, input.session_id || process.env[SESSION_ID_ENV]); |
| 105 | teardownBrokerSession({ |
| 106 | endpoint: brokerEndpoint, |
| 107 | pidFile, |
| 108 | logFile, |
| 109 | sessionDir, |
| 110 | pid, |
| 111 | killProcess: terminateProcessTree |
| 112 | }); |
| 113 | clearBrokerSession(cwd); |
| 114 | } |
| 115 | |
| 116 | async function main() { |
| 117 | const input = readHookInput(); |
no test coverage detected