tianji/src/server/main.ts

34 lines
859 B
TypeScript
Raw Normal View History

2023-09-02 12:13:50 +00:00
import 'dotenv/config';
import './init.js';
import { initUdpServer } from './udp/server.js';
2023-10-03 11:47:17 +00:00
import { createServer } from 'http';
import { initSocketio } from './ws/index.js';
import { monitorManager } from './model/monitor/index.js';
import { env } from './utils/env.js';
import { initCronjob } from './cronjob/index.js';
import { logger } from './utils/logger.js';
import { app } from './app.js';
import { runMQWorker } from './mq/worker.js';
2023-09-02 17:01:55 +00:00
2024-01-13 10:16:09 +00:00
const port = env.port;
2023-08-31 13:17:57 +00:00
2023-10-03 11:47:17 +00:00
const httpServer = createServer(app);
2023-08-31 13:17:57 +00:00
initUdpServer(port);
2023-10-03 11:47:17 +00:00
initSocketio(httpServer);
2023-09-18 08:08:16 +00:00
initCronjob();
runMQWorker();
2023-10-04 17:56:33 +00:00
monitorManager.startAll();
2023-10-03 11:47:17 +00:00
httpServer.listen(port, () => {
logger.info(`Server is listening on port ${port}...`);
if (env.allowOpenapi) {
logger.info(`Openapi UI: http://127.0.0.1:${port}/open/_ui`);
}
logger.info(`Website: http://127.0.0.1:${port}`);
2023-08-31 13:17:57 +00:00
});