SignallingServer can't be stopped from admin dashboard website

Description

After clicking "start" on the SignallingServer tab, the signalling server and the TURN server start. When clicking "stop" and then clicking "start" again, en error is shown:

Error: listen EADDRINUSE: address already in use :::80
    at Server.setupListenHandle [as _listen2] (node:net:1305:16)
    at listenInCluster (node:net:1353:12)
    at Server.listen (node:net:1440:7)
    at Object.<anonymous> (C:\Users\Rouben\Desktop\UE_VA_Streaming_Dashboard\Server\SignalingServer\cirrus.js:324:6)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47
Emitted 'error' event on WebSocketServer instance at:
    at Server.emit (node:events:394:28)
    at emitErrorNT (node:net:1332:8)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'EADDRINUSE',
  errno: -4091,
  syscall: 'listen',
  address: '::',
  port: 80
}
SSERVER terminated with code 0

The problem is, that although the output says SSERVER terminated with code null after clicking "stop", the Signalling Server isn't actually killed in the background. Thus, it's still running and blocking port 80, preventing it from being started (again).

The reason for this behaviour is, that in server.js in line 250-280 (start-sserver) the SSERVER object is the result of executing a PowerShell script using spawn.

SSERVER = spawn('powershell', ['.\\SignalingServer\\platform_scripts\\cmd\\Start_WithTURN_SignallingServer.ps1'])

Killing this child process in line 368 SSERVER.kill() only kills this PowerShell script. The actual SignallingServer however is called by this script and executed as a child process. That means killing SSERVER only kills the PowerShell script, but not it's child processes resulting in the SignallingServer not actually being killed.

Solution

To solve this issue, somehow the actual SignallingServer process needs to be killed inside stop-signalling-server (line 335). One could spawn the cirrus script directly as being done before (commented line 253), but in that case starting and handling the TURN Server needs to be done manually as well.