stopServer static method

void stopServer()

Implementation

static void stopServer() {
  if (_serverProcess != null) {
    try {
      _serverProcess!.kill();
    } catch (e) {
      print("Error killing server process: $e");
    }

    if (Platform.isWindows) {
      try {
        Process.runSync('taskkill', [
          '/F',
          '/T',
          '/PID',
          _serverProcess!.pid.toString(),
        ], runInShell: true);
        print("Force killed server process with PID: ${_serverProcess!.pid}");
      } catch (e) {
        print("Error force killing server on Windows: $e");
      }
    }

    _serverProcess = null;
  }
}