midway-fatcms 0.0.1-beta.19 → 0.0.1-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,6 @@ interface HttpGetRes {
11
11
  */
12
12
  export declare class StaticController extends BaseApiController {
13
13
  protected ctx: Context;
14
- constructor();
15
14
  private getLocalPaths;
16
15
  private initNotFoundList;
17
16
  private responseLocalFile;
@@ -43,10 +43,6 @@ let notFoundListIsInit = false;
43
43
  * 静态文件代理功能
44
44
  */
45
45
  let StaticController = class StaticController extends BaseApiController_1.BaseApiController {
46
- constructor() {
47
- super();
48
- this.initNotFoundList();
49
- }
50
46
  getLocalPaths() {
51
47
  const appDir = this.app.getAppDir();
52
48
  const localDir = path.join(appDir, './public/static'); // 本地文件存储目录
@@ -125,6 +121,7 @@ let StaticController = class StaticController extends BaseApiController_1.BaseAp
125
121
  return false;
126
122
  }
127
123
  async proxyStaticFile(ossName, relativePath) {
124
+ this.initNotFoundList();
128
125
  const { localDir } = this.getLocalPaths();
129
126
  const PATH_CONFIG = getPathConfig(ossName);
130
127
  // 构建本地路径和远程路径
@@ -282,7 +279,6 @@ __decorate([
282
279
  __metadata("design:returntype", Promise)
283
280
  ], StaticController.prototype, "proxyStaticFile", null);
284
281
  StaticController = __decorate([
285
- (0, core_1.Controller)('/ns/static'),
286
- __metadata("design:paramtypes", [])
282
+ (0, core_1.Controller)('/ns/static')
287
283
  ], StaticController);
288
284
  exports.StaticController = StaticController;
@@ -36,6 +36,7 @@ export declare enum SysAsyncTaskStatus {
36
36
  PENDING = "PENDING",
37
37
  RUNNING = "RUNNING",
38
38
  SUCCEEDED = "SUCCEEDED",
39
+ PART_SUCCEEDED = "PART_SUCCEEDED",
39
40
  FAILED = "FAILED",
40
41
  CANCELLED = "CANCELLED",
41
42
  PAUSED = "PAUSED"
@@ -6,6 +6,7 @@ var SysAsyncTaskStatus;
6
6
  SysAsyncTaskStatus["PENDING"] = "PENDING";
7
7
  SysAsyncTaskStatus["RUNNING"] = "RUNNING";
8
8
  SysAsyncTaskStatus["SUCCEEDED"] = "SUCCEEDED";
9
+ SysAsyncTaskStatus["PART_SUCCEEDED"] = "PART_SUCCEEDED";
9
10
  SysAsyncTaskStatus["FAILED"] = "FAILED";
10
11
  SysAsyncTaskStatus["CANCELLED"] = "CANCELLED";
11
12
  SysAsyncTaskStatus["PAUSED"] = "PAUSED";
@@ -20,6 +20,7 @@ const keys_1 = require("../../libs/crud-pro/models/keys");
20
20
  const errorToString_1 = require("../../libs/utils/errorToString");
21
21
  const schedule_1 = require("../../schedule");
22
22
  const RedisKeys_1 = require("../../models/RedisKeys");
23
+ const END_STATUS_LIST = [AsyncTaskModel_1.SysAsyncTaskStatus.SUCCEEDED, AsyncTaskModel_1.SysAsyncTaskStatus.FAILED, AsyncTaskModel_1.SysAsyncTaskStatus.PART_SUCCEEDED];
23
24
  class AsyncTaskRunner {
24
25
  constructor() {
25
26
  this.isBusy = false;
@@ -32,9 +33,14 @@ class AsyncTaskRunner {
32
33
  this.isBusy = true;
33
34
  for (let i = 0; i < taskList.length; i++) {
34
35
  const taskElement = taskList[i];
36
+ taskElement.task_status = AsyncTaskModel_1.SysAsyncTaskStatus.RUNNING;
35
37
  try {
36
38
  // 任务状态的设置在自定义的执行器里面。
37
39
  await this.executeTask(taskElement);
40
+ // 当前不是终止状态,并且没有异常就设置成成功。
41
+ if (!END_STATUS_LIST.includes(taskElement.task_status)) {
42
+ taskElement.task_status = AsyncTaskModel_1.SysAsyncTaskStatus.SUCCEEDED;
43
+ }
38
44
  }
39
45
  catch (error) {
40
46
  taskElement.task_status = AsyncTaskModel_1.SysAsyncTaskStatus.FAILED;
@@ -191,6 +197,7 @@ let AsyncTaskRunnerService = class AsyncTaskRunnerService extends BaseService_1.
191
197
  async isExistNewTask() {
192
198
  // 刚启动,没有检查过。
193
199
  if (!ASYNC_TASK_RUNTIME_OBJ.LAST_CHECK_ASYNC_TASK_UPDATE_TIME) {
200
+ ASYNC_TASK_RUNTIME_OBJ.LAST_CHECK_ASYNC_TASK_UPDATE_TIME = Date.now();
194
201
  return true;
195
202
  }
196
203
  //Redis没有任何内容
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midway-fatcms",
3
- "version": "0.0.1-beta.19",
3
+ "version": "0.0.1-beta.20",
4
4
  "description": "This is a midway component sample",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -42,10 +42,6 @@ export class StaticController extends BaseApiController {
42
42
  @Inject()
43
43
  protected ctx: Context;
44
44
 
45
- constructor() {
46
- super();
47
- this.initNotFoundList();
48
- }
49
45
 
50
46
  private getLocalPaths(): any {
51
47
  const appDir = this.app.getAppDir();
@@ -134,6 +130,7 @@ export class StaticController extends BaseApiController {
134
130
 
135
131
  @All('/:ossName/:relativePath+')
136
132
  async proxyStaticFile(@Param('ossName') ossName: string, @Param('relativePath') relativePath: string) {
133
+ this.initNotFoundList();
137
134
  const { localDir } = this.getLocalPaths();
138
135
  const PATH_CONFIG = getPathConfig(ossName);
139
136
 
@@ -41,8 +41,9 @@ export type SysAsyncTaskPartial = Partial<SysAsyncTaskEntity>;
41
41
  export enum SysAsyncTaskStatus {
42
42
  PENDING = 'PENDING', // 等待中,还未进入排队
43
43
  RUNNING = 'RUNNING', // 运行中
44
- SUCCEEDED = 'SUCCEEDED',
45
- FAILED = 'FAILED',
44
+ SUCCEEDED = 'SUCCEEDED', // 终止状态:全部成功
45
+ PART_SUCCEEDED = 'PART_SUCCEEDED',// 终止状态:部分成功
46
+ FAILED = 'FAILED', // 终止状态:失败
46
47
  CANCELLED = 'CANCELLED', // 取消
47
48
  PAUSED = 'PAUSED', // 暂停
48
49
  }
@@ -11,6 +11,8 @@ import { errorToString } from '@/libs/utils/errorToString';
11
11
  import { ANONYMOUS_CONTEXT } from '@/schedule';
12
12
  import { RedisKeys } from '@/models/RedisKeys';
13
13
 
14
+ const END_STATUS_LIST = [SysAsyncTaskStatus.SUCCEEDED, SysAsyncTaskStatus.FAILED, SysAsyncTaskStatus.PART_SUCCEEDED];
15
+
14
16
  class AsyncTaskRunner {
15
17
  isBusy = false;
16
18
  taskHandlerMap: Map<string, ISysAsyncTaskHandler> = new Map();
@@ -24,10 +26,17 @@ class AsyncTaskRunner {
24
26
 
25
27
  for (let i = 0; i < taskList.length; i++) {
26
28
  const taskElement = taskList[i];
27
-
29
+ taskElement.task_status = SysAsyncTaskStatus.RUNNING;
30
+
28
31
  try {
29
32
  // 任务状态的设置在自定义的执行器里面。
30
33
  await this.executeTask(taskElement);
34
+
35
+ // 当前不是终止状态,并且没有异常就设置成成功。
36
+ if (!END_STATUS_LIST.includes(taskElement.task_status)) {
37
+ taskElement.task_status = SysAsyncTaskStatus.SUCCEEDED;
38
+ }
39
+
31
40
  } catch (error) {
32
41
  taskElement.task_status = SysAsyncTaskStatus.FAILED;
33
42
  taskElement.error_message = errorToString(error);
@@ -220,6 +229,7 @@ export class AsyncTaskRunnerService extends BaseService implements IScheduleServ
220
229
  private async isExistNewTask(): Promise<boolean> {
221
230
  // 刚启动,没有检查过。
222
231
  if (!ASYNC_TASK_RUNTIME_OBJ.LAST_CHECK_ASYNC_TASK_UPDATE_TIME) {
232
+ ASYNC_TASK_RUNTIME_OBJ.LAST_CHECK_ASYNC_TASK_UPDATE_TIME = Date.now();
223
233
  return true;
224
234
  }
225
235