mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 06:46:09 +08:00
21 lines
648 B
TypeScript
21 lines
648 B
TypeScript
import { Server, ServerCredentials } from '@grpc/grpc-js';
|
|
import { CronService } from '../protos/cron';
|
|
import { addCron } from './addCron';
|
|
import { delCron } from './delCron';
|
|
import { HealthService } from '../protos/health';
|
|
import { check } from './health';
|
|
import config from '../config';
|
|
import Logger from '../loaders/logger';
|
|
|
|
const server = new Server();
|
|
server.addService(HealthService, { check });
|
|
server.addService(CronService, { addCron, delCron });
|
|
server.bindAsync(
|
|
`localhost:${config.cronPort}`,
|
|
ServerCredentials.createInsecure(),
|
|
() => {
|
|
server.start();
|
|
Logger.debug(`✌️ 定时服务启动成功!`);
|
|
},
|
|
);
|