26 lines
848 B
TypeScript
26 lines
848 B
TypeScript
import {TcpServer} from "./tcp_server";
|
|
import {UdpServer} from "./udp_server";
|
|
import dotenv from "dotenv";
|
|
import path from "path";
|
|
|
|
dotenv.config({ path: path.join('..', '.env') });
|
|
|
|
const UDP_PORT: number = process.env.UDP_PORT ? parseInt(process.env.UDP_PORT) : 41234;
|
|
const TCP_PORT: number = process.env.TCP_PORT? parseInt(process.env.TCP_PORT): 41233
|
|
const HOST: string = process.env.HOST || '0.0.0.0';
|
|
|
|
// Function to handle server logs (not needed when starting directly)
|
|
const handleServerLogs = (serverName: string): void => {
|
|
console.log(`${serverName} started successfully.`);
|
|
};
|
|
|
|
// Start the UDP server
|
|
const udpServer = new UdpServer(HOST, UDP_PORT);
|
|
udpServer.start();
|
|
handleServerLogs('UDP Server');
|
|
|
|
// Start the TCP server
|
|
const tcpServer = new TcpServer(HOST, TCP_PORT);
|
|
tcpServer.start();
|
|
handleServerLogs('TCP Server');
|