|
@@ -865,6 +865,7 @@ class PublishService {
|
|
|
return deployIsOnline;
|
|
|
} catch (e) {
|
|
|
print('get remote statues error: $e');
|
|
|
+ Logger.warning('get remote statues error: $e');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
@@ -877,78 +878,119 @@ class PublishService {
|
|
|
var serverIsOnline = result.code == 0;
|
|
|
return serverIsOnline;
|
|
|
} catch (e) {
|
|
|
- print('get remote statues error: $e');
|
|
|
+ print('get server statues error: $e');
|
|
|
+ Logger.warning('get server statues error: $e');
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//关闭
|
|
|
Future remoteStopServer(String ip) async {
|
|
|
- final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- await rpc.deployPlatform.stopServer();
|
|
|
+ try {
|
|
|
+ final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ await rpc.deployPlatform.stopServer();
|
|
|
+ } catch (e) {
|
|
|
+ Logger.error(e);
|
|
|
+ print('remoteStopServer error: $e');
|
|
|
+ Logger.warning('remoteStopServer error: $e');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//启动
|
|
|
Future remoteStartServer(String ip) async {
|
|
|
- final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- await rpc.deployPlatform.start();
|
|
|
+ try {
|
|
|
+ final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ await rpc.deployPlatform.start();
|
|
|
+ } catch (e) {
|
|
|
+ print('remoteStartServer error: $e');
|
|
|
+ Logger.warning('remoteStartServer error: $e');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//一键部署
|
|
|
Future remoteDeploy(String ip, String recordId) async {
|
|
|
- var recordDetal = await new PackageService().getDetailAsync(recordId);
|
|
|
- var rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- var request = DeployRequest();
|
|
|
- request.isUpgradeServer = recordDetal.isServerSelected!;
|
|
|
-
|
|
|
- var packageLogs = recordDetal.PackageLogs ?? [];
|
|
|
- if (request.isUpgradeServer) {
|
|
|
- String? serverZipUrl;
|
|
|
- for (String str in packageLogs.where((s) =>
|
|
|
- s.contains('Upload Successful') && s.contains('Flyinsono_Server'))) {
|
|
|
- final match = RegExp(
|
|
|
- r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
|
|
|
- .firstMatch(str);
|
|
|
- if (match != null) {
|
|
|
- serverZipUrl = match.group(0);
|
|
|
- break;
|
|
|
+ try {
|
|
|
+ var recordDetal = await new PackageService().getDetailAsync(recordId);
|
|
|
+ var rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ var request = DeployRequest();
|
|
|
+ request.isUpgradeServer = recordDetal.isServerSelected!;
|
|
|
+
|
|
|
+ var packageLogs = recordDetal.PackageLogs ?? [];
|
|
|
+ if (request.isUpgradeServer) {
|
|
|
+ String? serverZipUrl;
|
|
|
+ for (String str in packageLogs.where((s) =>
|
|
|
+ s.contains('Upload Successful') &&
|
|
|
+ s.contains('Flyinsono_Server'))) {
|
|
|
+ final match = RegExp(
|
|
|
+ r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+')
|
|
|
+ .firstMatch(str);
|
|
|
+ if (match != null) {
|
|
|
+ serverZipUrl = match.group(0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ request.serverZipUrl = serverZipUrl;
|
|
|
}
|
|
|
- request.serverZipUrl = serverZipUrl;
|
|
|
+ request.upgradeSettings =
|
|
|
+ packageLogs.firstWhere((s) => s.contains('"Description":')).trim();
|
|
|
+ await rpc.deployPlatform.deployAsync(request);
|
|
|
+ } catch (e) {
|
|
|
+ print('remoteDeploy error: $e');
|
|
|
+ Logger.warning('remoteDeploy error: $e');
|
|
|
}
|
|
|
- request.upgradeSettings =
|
|
|
- packageLogs.firstWhere((s) => s.contains('"Description":')).trim();
|
|
|
- await rpc.deployPlatform.deployAsync(request);
|
|
|
}
|
|
|
|
|
|
//获取远程配置
|
|
|
Future<String> readAppSettingsJsonAsync(String ip) async {
|
|
|
- final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- var rpcResult = await rpc.deployPlatform.readAppSettingsJsonAsync();
|
|
|
- return rpcResult;
|
|
|
+ try {
|
|
|
+ final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ var rpcResult = await rpc.deployPlatform.readAppSettingsJsonAsync();
|
|
|
+ return rpcResult;
|
|
|
+ } catch (e) {
|
|
|
+ print('readAppSettingsJsonAsync error: $e');
|
|
|
+ Logger.warning('readAppSettingsJsonAsync error: $e');
|
|
|
+ return "";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//修改远程配置
|
|
|
Future modifyAppSettingsJsonAsync(String ip, String json) async {
|
|
|
- final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- await rpc.deployPlatform.modifyAppSettingsJsonAsync(
|
|
|
- new ModifyAppSettingsJsonRequest(json: json));
|
|
|
+ try {
|
|
|
+ final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ await rpc.deployPlatform.modifyAppSettingsJsonAsync(
|
|
|
+ new ModifyAppSettingsJsonRequest(json: json));
|
|
|
+ } catch (e) {
|
|
|
+ print('modifyAppSettingsJsonAsync error: $e');
|
|
|
+ Logger.warning('modifyAppSettingsJsonAsync error: $e');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//获取部署日志
|
|
|
Future<List<String>> getPublishPackageLogsAsync(String ip) async {
|
|
|
- final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
- var result = await rpc.deployPlatform.getPublishPackageLogsAsync();
|
|
|
- return result;
|
|
|
+ try {
|
|
|
+ final rpc = JsonRpcProxy(host: ip + ":8305");
|
|
|
+ var result = await rpc.deployPlatform.getPublishPackageLogsAsync();
|
|
|
+ return result;
|
|
|
+ } catch (e) {
|
|
|
+ print('getPublishPackageLogsAsync error: $e');
|
|
|
+ Logger.warning('getPublishPackageLogsAsync error: $e');
|
|
|
+ return ["not on line"];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//保存部署日志
|
|
|
Future<bool> saveLogsAsync(String id, List<String> logList) async {
|
|
|
- var logs = json.encode(logList);
|
|
|
- final rpc = GetIt.instance.get<JsonRpcProxy>();
|
|
|
- var result = await rpc.deployPlatform
|
|
|
- .saveLogsAsync(new SaveLogsRequest(id: id, logs: logs));
|
|
|
- return result;
|
|
|
+ try {
|
|
|
+ var logs = json.encode(logList);
|
|
|
+ final rpc = GetIt.instance.get<JsonRpcProxy>();
|
|
|
+ var result = await rpc.deployPlatform
|
|
|
+ .saveLogsAsync(new SaveLogsRequest(id: id, logs: logs));
|
|
|
+ return result;
|
|
|
+ } catch (e) {
|
|
|
+ print('saveLogsAsync error: $e');
|
|
|
+ Logger.warning('saveLogsAsync error: $e');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//查询日志
|