2026-04-05 23:49:25 +08:00
|
|
|
import { logger } from '@certd/basic';
|
|
|
|
|
import { Config, Configuration, IMidwayContainer } from '@midwayjs/core';
|
2024-07-15 00:30:33 +08:00
|
|
|
import { Cron } from './cron.js';
|
2023-01-29 13:44:19 +08:00
|
|
|
|
|
|
|
|
// ... (see below) ...
|
|
|
|
|
@Configuration({
|
|
|
|
|
namespace: 'cron',
|
|
|
|
|
//importConfigs: [join(__dirname, './config')],
|
|
|
|
|
})
|
|
|
|
|
export class CronConfiguration {
|
|
|
|
|
@Config()
|
|
|
|
|
config;
|
|
|
|
|
cron: Cron;
|
|
|
|
|
async onReady(container: IMidwayContainer) {
|
2026-04-05 23:49:25 +08:00
|
|
|
logger.info('cron start');
|
2023-01-29 13:44:19 +08:00
|
|
|
this.cron = new Cron({
|
2026-04-05 23:49:25 +08:00
|
|
|
logger: logger,
|
2023-01-29 13:44:19 +08:00
|
|
|
...this.config,
|
|
|
|
|
});
|
|
|
|
|
container.registerObject('cron', this.cron);
|
2024-08-05 16:00:04 +08:00
|
|
|
this.cron.start();
|
2026-04-05 23:49:25 +08:00
|
|
|
logger.info('cron started');
|
2023-01-29 13:44:19 +08:00
|
|
|
}
|
|
|
|
|
}
|