mirror of
https://github.com/certd/certd.git
synced 2026-07-14 09:27:32 +08:00
chore: format
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { logger } from '@certd/basic';
|
||||
import { Config, Configuration, IMidwayContainer } from '@midwayjs/core';
|
||||
import { Cron } from './cron.js';
|
||||
import { logger } from "@certd/basic";
|
||||
import { Config, Configuration, IMidwayContainer } from "@midwayjs/core";
|
||||
import { Cron } from "./cron.js";
|
||||
|
||||
// ... (see below) ...
|
||||
@Configuration({
|
||||
namespace: 'cron',
|
||||
namespace: "cron",
|
||||
//importConfigs: [join(__dirname, './config')],
|
||||
})
|
||||
export class CronConfiguration {
|
||||
@@ -12,13 +12,13 @@ export class CronConfiguration {
|
||||
config;
|
||||
cron: Cron;
|
||||
async onReady(container: IMidwayContainer) {
|
||||
logger.info('cron start');
|
||||
logger.info("cron start");
|
||||
this.cron = new Cron({
|
||||
logger: logger,
|
||||
...this.config,
|
||||
});
|
||||
container.registerObject('cron', this.cron);
|
||||
container.registerObject("cron", this.cron);
|
||||
this.cron.start();
|
||||
logger.info('cron started');
|
||||
logger.info("cron started");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import parser from 'cron-parser';
|
||||
import { ILogger, logger } from '@certd/basic';
|
||||
import parser from "cron-parser";
|
||||
import { ILogger, logger } from "@certd/basic";
|
||||
|
||||
export type CronTaskReq = {
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ export class Cron {
|
||||
}
|
||||
|
||||
start() {
|
||||
this.logger.info('[cron] start');
|
||||
this.logger.info("[cron] start");
|
||||
this.queue.forEach(task => {
|
||||
task.genNextTime();
|
||||
});
|
||||
@@ -85,11 +85,11 @@ export class Cron {
|
||||
}
|
||||
this.logger.info(`[cron] register cron : [${req.name}] ,${req.cron}`);
|
||||
|
||||
this.remove(req.name)
|
||||
this.remove(req.name);
|
||||
|
||||
const task = new CronTask(req, this.logger);
|
||||
this.queue.push(task);
|
||||
this.logger.info('当前定时任务数量:', this.getTaskSize());
|
||||
this.logger.info("当前定时任务数量:", this.getTaskSize());
|
||||
}
|
||||
|
||||
remove(taskName: string) {
|
||||
@@ -99,7 +99,7 @@ export class Cron {
|
||||
this.queue[index].stop();
|
||||
this.queue.splice(index, 1);
|
||||
}
|
||||
this.logger.info('当前定时任务数量:', this.getTaskSize());
|
||||
this.logger.info("当前定时任务数量:", this.getTaskSize());
|
||||
}
|
||||
|
||||
getTaskSize() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// src/index.ts
|
||||
export { CronConfiguration as Configuration } from './configuration.js';
|
||||
export { CronConfiguration as Configuration } from "./configuration.js";
|
||||
// export * from './controller/user';
|
||||
// export * from './controller/api';
|
||||
// export * from './service/user';
|
||||
|
||||
Reference in New Issue
Block a user