bug fixed

This commit is contained in:
Toki 2025-01-01 10:14:06 +09:00
parent f99c3a3f1a
commit 8978fa44fc
3 changed files with 19 additions and 9 deletions

View file

@ -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<String, List<String>> 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<String> 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.';
}
}
}

View file

@ -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;
}

View file

@ -965,6 +965,9 @@ DataZip _$DataZipFromJson(Map<String, dynamic> json) => DataZip()
..setResult = json['setResult'] as String?
..setExitCode = json['setExitCode'] as String?
..showPrint = json['showPrint'] as bool?
..ignorePattern = (json['ignorePattern'] as List<dynamic>?)
?.map((e) => e as String)
.toList()
..zipFile = json['zipFile'] as String
..zipList =
(json['zipList'] as List<dynamic>).map((e) => e as String).toList();
@ -975,6 +978,7 @@ Map<String, dynamic> _$DataZipToJson(DataZip instance) => <String, dynamic>{
'setResult': instance.setResult,
'setExitCode': instance.setExitCode,
'showPrint': instance.showPrint,
'ignorePattern': instance.ignorePattern,
'zipFile': instance.zipFile,
'zipList': instance.zipList,
};