* Restarts the ongoing program.
()
| 182 | * Restarts the ongoing program. |
| 183 | */ |
| 184 | public async restart(): Promise<void> { |
| 185 | if (!this.run) { |
| 186 | return; |
| 187 | } |
| 188 | |
| 189 | // connections must be closed, or the process will wait forever: |
| 190 | this.closeAllConnections(); |
| 191 | |
| 192 | // Clear the program so that termination logic doesn't run. |
| 193 | const program = this.program; |
| 194 | if (program) { |
| 195 | this.program = undefined; |
| 196 | await program.stop(); |
| 197 | } |
| 198 | |
| 199 | // relaunch the program, releasing the initial cancellation token: |
| 200 | const cts = CancellationTokenSource.withTimeout(this.run.params.timeout); |
| 201 | await this.launchProgram({ |
| 202 | ...this.run, |
| 203 | context: { |
| 204 | ...this.run.context, |
| 205 | cancellationToken: cts.token, |
| 206 | }, |
| 207 | }); |
| 208 | } |
| 209 | |
| 210 | public targetList(): ITarget[] { |
| 211 | return [...this.targets.value()]; |
no test coverage detected