This repository was archived by the owner on Nov 13, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,12 @@ import InstanceControlSubsystem from "../service/system_instance_control";
2525
2626// 创建计划任务
2727routerApp . on ( "schedule/register" , ( ctx , data ) => {
28- InstanceControlSubsystem . registerScheduleJob ( data ) ;
29- protocol . response ( ctx , true ) ;
28+ try {
29+ InstanceControlSubsystem . registerScheduleJob ( data ) ;
30+ protocol . response ( ctx , true ) ;
31+ } catch ( error ) {
32+ protocol . responseError ( ctx , error ) ;
33+ }
3034} ) ;
3135
3236// 获取任务列表
Original file line number Diff line number Diff line change @@ -91,10 +91,12 @@ class InstanceControlSubsystem {
9191 if ( ! this . taskMap . has ( key ) ) {
9292 this . taskMap . set ( key , [ ] ) ;
9393 }
94+ if ( this . taskMap . get ( key ) ?. length > 8 ) throw new Error ( "无法继续创建计划任务,以达到上限" ) ;
9495 if ( ! this . checkTask ( key , task . name ) ) throw new Error ( "已存在重复的任务" ) ;
95- let job : IScheduleJob ;
9696 if ( needStore ) logger . info ( `创建计划任务 ${ task . name } :\n${ JSON . stringify ( task ) } ` ) ;
9797
98+ let job : IScheduleJob ;
99+
98100 // 最小间隔时间检查
99101 if ( task . type === 1 ) {
100102 let internalTime = Number ( task . time ) ;
@@ -232,6 +234,11 @@ class InstanceControlSubsystem {
232234 }
233235 }
234236 }
237+
238+ private checkScheduledTaskLimit ( instanceUuid : string ) {
239+ for ( const iterator of this . taskMap ) {
240+ }
241+ }
235242}
236243
237244export default new InstanceControlSubsystem ( ) ;
You can’t perform that action at this time.
0 commit comments