@@ -55,10 +55,6 @@ export default class SandboxRuntime {
55
55
56
56
// 直接运行脚本
57
57
start ( script : ScriptRunResouce ) : Promise < boolean > {
58
- // 存在先将资源释放
59
- if ( this . execScripts . has ( script . id ) ) {
60
- this . stop ( script . id ) ;
61
- }
62
58
return this . execScript ( script ) ;
63
59
}
64
60
@@ -112,13 +108,13 @@ export default class SandboxRuntime {
112
108
// 执行脚本
113
109
execScript ( script : ScriptRunResouce ) {
114
110
const logger = this . logger . with ( { scriptId : script . id , name : script . name } ) ;
115
- let exec : ExecScript ;
116
111
if ( this . execScripts . has ( script . id ) ) {
117
- exec = this . execScripts . get ( script . id ) ! ;
118
- } else {
119
- exec = new ExecScript ( script , this . message ) ;
120
- this . execScripts . set ( script . id , exec ) ;
112
+ // 释放掉资源
113
+ // 暂未实现执行完成后立马释放,会在下一次执行时释放
114
+ this . stop ( script . id ) ;
121
115
}
116
+ const exec = new ExecScript ( script , this . message ) ;
117
+ this . execScripts . set ( script . id , exec ) ;
122
118
this . message . send ( "scriptRunStatus" , [
123
119
exec . scriptRes . id ,
124
120
SCRIPT_RUN_STATUS_RUNNING ,
@@ -161,7 +157,6 @@ export default class SandboxRuntime {
161
157
throw new Error ( "错误的crontab表达式" ) ;
162
158
}
163
159
let flag = false ;
164
- const exec = new ExecScript ( script , this . message ) ;
165
160
const cronJobList : Array < CronJob > = [ ] ;
166
161
script . metadata . crontab . forEach ( ( val ) => {
167
162
let oncePos = 0 ;
@@ -196,7 +191,6 @@ export default class SandboxRuntime {
196
191
crontab . stop ( ) ;
197
192
} ) ;
198
193
} else {
199
- this . execScripts . set ( script . id , exec ) ;
200
194
this . cronJob . set ( script . id , cronJobList ) ;
201
195
}
202
196
return Promise . resolve ( ! flag ) ;
0 commit comments