* Immediately kill the PTY and remove the session.
(token: string)
| 123 | * Immediately kill the PTY and remove the session. |
| 124 | */ |
| 125 | destroy(token: string): void { |
| 126 | const session = this.sessions.get(token); |
| 127 | if (!session) return; |
| 128 | |
| 129 | this.sessions.delete(token); |
| 130 | |
| 131 | if (session.graceTimer) { |
| 132 | clearTimeout(session.graceTimer); |
| 133 | session.graceTimer = null; |
| 134 | } |
| 135 | |
| 136 | if ( |
| 137 | session.ws && |
| 138 | session.ws.readyState !== 2 /* CLOSING */ && |
| 139 | session.ws.readyState !== 3 /* CLOSED */ |
| 140 | ) { |
| 141 | session.ws.close(1000, "Session destroyed"); |
| 142 | } |
| 143 | |
| 144 | try { |
| 145 | session.pty.kill("SIGHUP"); |
| 146 | } catch { |
| 147 | // PTY may already be dead |
| 148 | } |
| 149 | setTimeout(() => { |
| 150 | try { |
| 151 | session.pty.kill("SIGKILL"); |
| 152 | } catch { |
| 153 | // Already dead |
| 154 | } |
| 155 | }, 5000); |
| 156 | } |
| 157 | |
| 158 | /** Returns summary info for all sessions (used by the REST API). */ |
| 159 | list(): SessionInfo[] { |
no test coverage detected