restart method
Restarts the proxy server.
Closes the existing server and health check timer, then starts a new server on the same port. This is useful when the app returns to the foreground after the OS has killed the server socket in the background.
Implementation
Future<void> restart() async {
logD('Proxy server restart requested...');
_healthCheckTimer?.cancel();
_healthCheckTimer = null;
try {
await server?.close();
} catch (_) {
// Server may already be dead (killed by OS in background).
}
server = null;
await start();
}