Общая система сборки у репозиториев, определение порта

This commit is contained in:
RoyceDa
2026-02-11 10:15:02 +02:00
parent 195fe4759f
commit 867137a5fa
8 changed files with 139 additions and 32 deletions

View File

@@ -62,14 +62,14 @@ public class Boot {
private Configuration configuration;
private ServerConfiguration serverConfiguration;
public Boot() {
public Boot(int port) {
this.packetManager = new PacketManager();
this.eventManager = new EventManager();
this.onlineManager = new OnlineManager();
this.logger = new Logger(LogLevel.INFO);
this.serverAdapter = new ServerAdapter(this.eventManager);
this.server = new Server(new Settings(
8881,
port,
30
), packetManager, this.serverAdapter);
this.clientManager = new ClientManager(server);

View File

@@ -2,13 +2,37 @@ package com.rosetta.im;
public class Main {
public static void main(String[] args) {
int port = resolvePort(args);
/**
* Регистрация всех пакетов и их обработчиков
*/
Boot boot = new Boot();
Boot boot = new Boot(port);
/**
* Стартуем сервер
*/
boot.bootstrap();
}
private static int resolvePort(String[] args) {
// Если порт указан аргументом — используем его.
if (args != null && args.length > 0) {
try {
return Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) {
}
}
// Если порт задан в окружении — используем его.
String envPort = System.getenv("PORT");
if (envPort != null && !envPort.isBlank()) {
try {
return Integer.parseInt(envPort);
} catch (NumberFormatException ignored) {
}
}
// Значение по умолчанию.
return 8080;
}
}