()
| 180 | } |
| 181 | |
| 182 | shutdown() { |
| 183 | if (!this.running) return; |
| 184 | |
| 185 | getLogger().info('[WorkerManager] Shutdown'); |
| 186 | |
| 187 | Atomics.or(this.view, 0, 0b100); |
| 188 | Atomics.notify(this.view, 0); |
| 189 | |
| 190 | const timeout = setTimeout(() => { |
| 191 | getLogger().error('[WorkerManager] Shutdown timeout, force terminate'); |
| 192 | this.worker.terminate(); |
| 193 | }, 5000); |
| 194 | |
| 195 | this.worker.on('exit', () => { |
| 196 | clearTimeout(timeout); |
| 197 | getLogger().info('[WorkerManager] Shutdown completed'); |
| 198 | }); |
| 199 | } |
| 200 | |
| 201 | isRunning(): boolean { |
| 202 | return this.running; |
no test coverage detected