From 8978fa44fc392e0a48e9258eaead310fd32d8bac Mon Sep 17 00:00:00 2001 From: Toki Date: Wed, 1 Jan 2025 10:14:06 +0900 Subject: [PATCH] bug fixed --- lib/cli/commands/command_scheduler.dart | 17 ++++++++++------- .../commands/scheduler/scheduler_manager.dart | 7 +++++-- lib/oto/data/command_data.g.dart | 4 ++++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/cli/commands/command_scheduler.dart b/lib/cli/commands/command_scheduler.dart index ea9aeb2..567149d 100644 --- a/lib/cli/commands/command_scheduler.dart +++ b/lib/cli/commands/command_scheduler.dart @@ -6,17 +6,18 @@ import 'package:dart_framework/utils/system_util.dart'; import 'package:oto_cli/cli/commands/scheduler/scheduler_manager.dart'; class CommandScheduler extends CommandBase { - @override Map> get arguments => { '-l': ["Shows the currently operational schedulers."], '-r {file}': ["Register the defined file (yaml) with the scheduler."], - '-u {alias}': ["Unregister schedules registered with the scheduler based on alias."], + '-u {alias}': [ + "Unregister schedules registered with the scheduler based on alias." + ], '-e {alias} {bool}': ["Enables/disables the registered scheduler."] }; @override String get name => 'scheduler'; - final SchedulerManager _scheduler = SchedulerManager(); + final SchedulerManager _scheduler = SchedulerManager.create(); @override Future execute(List parameters) async { @@ -46,7 +47,7 @@ class CommandScheduler extends CommandBase { var alias = parameters[i + 1]; // ignore: sdk_version_since var enable = bool.tryParse(parameters[i + 2]); - if(enable == null) { + if (enable == null) { printHelp(); } else { await _scheduler.enableScheduler(alias, enable); @@ -58,10 +59,12 @@ class CommandScheduler extends CommandBase { } //================== for Debug ==================// - else if (item.startsWith('-s')) { //hidden: start process + else if (item.startsWith('-s')) { + //hidden: start process await _scheduler.start(); break; - } else if (item.startsWith('-t')) { //hidden: terminate process + } else if (item.startsWith('-t')) { + //hidden: terminate process await _scheduler.terminate(); break; } else { @@ -75,4 +78,4 @@ class CommandScheduler extends CommandBase { String getDescription() { return ':::: Run as a service on the background.'; } -} \ No newline at end of file +} diff --git a/lib/cli/commands/scheduler/scheduler_manager.dart b/lib/cli/commands/scheduler/scheduler_manager.dart index 53d4ec6..6ac72c6 100644 --- a/lib/cli/commands/scheduler/scheduler_manager.dart +++ b/lib/cli/commands/scheduler/scheduler_manager.dart @@ -246,9 +246,12 @@ class SchedulerManager { var processes = await findProcess('scheduler -s'); for (var process in processes) { var processName = process.name; - if (processName.contains('main.dart scheduler -s') || - processName.contains('$appName scheduler -s')) { + if (processName.contains('main.dart scheduler -s')) { _currentScheduler = process; + } else if (processName.contains('$appName scheduler -s')) { + _currentScheduler = process; + } + if (_currentScheduler != null) { print('Scheduler is running on pid [${_currentScheduler!.pid}].'); break; } diff --git a/lib/oto/data/command_data.g.dart b/lib/oto/data/command_data.g.dart index 87011ad..d651dca 100644 --- a/lib/oto/data/command_data.g.dart +++ b/lib/oto/data/command_data.g.dart @@ -965,6 +965,9 @@ DataZip _$DataZipFromJson(Map json) => DataZip() ..setResult = json['setResult'] as String? ..setExitCode = json['setExitCode'] as String? ..showPrint = json['showPrint'] as bool? + ..ignorePattern = (json['ignorePattern'] as List?) + ?.map((e) => e as String) + .toList() ..zipFile = json['zipFile'] as String ..zipList = (json['zipList'] as List).map((e) => e as String).toList(); @@ -975,6 +978,7 @@ Map _$DataZipToJson(DataZip instance) => { 'setResult': instance.setResult, 'setExitCode': instance.setExitCode, 'showPrint': instance.showPrint, + 'ignorePattern': instance.ignorePattern, 'zipFile': instance.zipFile, 'zipList': instance.zipList, };