tianji/src/server/main.ts

31 lines
755 B
TypeScript
Raw Normal View History

2023-09-02 12:13:50 +00:00
import 'dotenv/config';
import './init';
import { initUdpServer } from './udp/server';
2023-10-03 11:47:17 +00:00
import { createServer } from 'http';
import { initSocketio } from './ws';
2023-10-04 17:56:33 +00:00
import { monitorManager } from './model/monitor';
2023-10-21 16:26:13 +00:00
import { env } from './utils/env';
import { initCronjob } from './cronjob';
2024-01-05 16:16:43 +00:00
import { logger } from './utils/logger';
import { app } from './app';
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();
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
});