mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-23 15:49:24 +03:00
[FEATURE] Автозапуск netty сервера при его настройке
This commit is contained in:
parent
e2c7b455d2
commit
0e215899e4
1 changed files with 14 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
import ru.gravit.launchserver.manangers.hook.BuildHookManager;
|
||||
import ru.gravit.launchserver.manangers.hook.SocketHookManager;
|
||||
import ru.gravit.launchserver.response.Response;
|
||||
import ru.gravit.launchserver.socket.NettyServerSocketHandler;
|
||||
import ru.gravit.launchserver.socket.ServerSocketHandler;
|
||||
import ru.gravit.launchserver.texture.RequestTextureProvider;
|
||||
import ru.gravit.launchserver.texture.TextureProvider;
|
||||
|
@ -289,6 +290,8 @@ public static void main(String... args) throws Throwable {
|
|||
|
||||
public final ServerSocketHandler serverSocketHandler;
|
||||
|
||||
public final NettyServerSocketHandler nettyServerSocketHandler;
|
||||
|
||||
private final AtomicBoolean started = new AtomicBoolean(false);
|
||||
|
||||
// Updates and profiles
|
||||
|
@ -450,6 +453,10 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
|
|||
modulesManager.postInitModules();
|
||||
// start updater
|
||||
this.updater = new Updater(this);
|
||||
if(config.netty != null)
|
||||
nettyServerSocketHandler = new NettyServerSocketHandler(this);
|
||||
else
|
||||
nettyServerSocketHandler = null;
|
||||
}
|
||||
|
||||
public static void initGson() {
|
||||
|
@ -587,6 +594,11 @@ public void rebindServerSocket() {
|
|||
CommonHelper.newThread("Server Socket Thread", false, serverSocketHandler).start();
|
||||
}
|
||||
|
||||
public void rebindNettyServerSocket() {
|
||||
nettyServerSocketHandler.close();
|
||||
CommonHelper.newThread("Netty Server Socket Thread", false, nettyServerSocketHandler).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (started.getAndSet(true))
|
||||
|
@ -596,6 +608,8 @@ public void run() {
|
|||
JVMHelper.RUNTIME.addShutdownHook(CommonHelper.newThread(null, false, this::close));
|
||||
CommonHelper.newThread("Command Thread", true, commandHandler).start();
|
||||
rebindServerSocket();
|
||||
if(config.netty != null)
|
||||
rebindNettyServerSocket();
|
||||
modulesManager.finishModules();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue