Fix Windows local node daemon arguments
build / Build Linux wallet (push) Successful in 2m32s
build / Build Windows wallet (push) Successful in 20m7s

This commit is contained in:
Codex Bot
2026-04-19 13:37:58 +02:00
parent 1d0041f8cb
commit a5a1548c94
+32 -21
View File
@@ -39,20 +39,9 @@ class WindowsLocalNodeService implements LocalNodeService {
@override
Future<bool> stop() async {
final effective = _resolveConfig(null);
final pidFile = File(await _pidFilePath());
if (!await pidFile.exists()) {
_logger.w('Local node pidfile not found at ${pidFile.path}');
return false;
}
final rawPid = await pidFile.readAsString();
final pid = int.tryParse(rawPid.trim());
if (pid == null) {
_logger.w('Local node pidfile invalid: $rawPid');
return false;
}
final killed = Process.killPid(pid);
if (!killed) {
_logger.w('Failed to terminate local node process ($pid)');
final stopped = await _stopViaRpc(effective);
if (!stopped) {
_logger.w('Failed to stop local node via RPC.');
return false;
}
return _waitForStop(effective);
@@ -86,7 +75,6 @@ class WindowsLocalNodeService implements LocalNodeService {
);
return false;
}
final pidFile = await _pidFilePath();
final daemonLogFile = await AppPaths.localNodeLogFile();
final launcherLogFile = await AppPaths.localNodeLauncherLogFile();
await launcherLogFile.parent.create(recursive: true);
@@ -97,8 +85,6 @@ class WindowsLocalNodeService implements LocalNodeService {
config.rpcHost,
'--rpc-bind-port',
config.rpcPort.toString(),
'--pidfile',
pidFile,
'--log-file',
daemonLogFile.path,
...config.extraArgs,
@@ -200,6 +186,35 @@ class WindowsLocalNodeService implements LocalNodeService {
}
}
Future<bool> _stopViaRpc(LocalNodeConfig config) async {
HttpClient? client;
try {
client = HttpClient();
final uri = Uri.parse('http://${config.rpcHost}:${config.rpcPort}/json_rpc');
final request = await client.postUrl(uri);
request.headers.contentType = ContentType.json;
request.write(jsonEncode({
'jsonrpc': '2.0',
'id': '0',
'method': 'stop_daemon',
}));
final response = await request.close();
final body = await utf8.decoder.bind(response).join();
if (response.statusCode != HttpStatus.ok) {
_logger.w(
'Local node stop_daemon returned HTTP ${response.statusCode}: $body',
);
return false;
}
return true;
} catch (error) {
_logger.w('Failed to call stop_daemon on local node: $error');
return false;
} finally {
client?.close(force: true);
}
}
LocalNodeConfig _resolveConfig(LocalNodeConfig? config) {
final base = config ?? _lastConfig ?? const LocalNodeConfig();
return _applyOverrides(base);
@@ -252,8 +267,4 @@ class WindowsLocalNodeService implements LocalNodeService {
}
return null;
}
Future<String> _pidFilePath() async {
return (await AppPaths.localNodePidFile()).path;
}
}