[FIX] Закрытие соеденения при выходе

This commit is contained in:
Gravit 2019-04-03 23:49:50 +07:00
parent 40d4003696
commit 8466894d49
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 8 additions and 1 deletions

View file

@ -139,7 +139,6 @@ public void run() {
public void initChannel(NioSocketChannel ch) {
ChannelPipeline pipeline = ch.pipeline();
//p.addLast(new LoggingHandler(LogLevel.INFO));
System.out.println("P!");
pipeline.addLast(new HttpServerCodec());
pipeline.addLast(new HttpObjectAggregator(65536));
pipeline.addLast(new WebSocketServerCompressionHandler());

View file

@ -5,6 +5,7 @@
import ru.gravit.launcher.events.request.ErrorRequestEvent;
import ru.gravit.launcher.request.RequestException;
import ru.gravit.launcher.request.ResultInterface;
import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper;
import java.io.IOException;
@ -44,6 +45,13 @@ public static void initWebSockets(String address) {
} catch (InterruptedException e) {
e.printStackTrace();
}
JVMHelper.RUNTIME.addShutdownHook(new Thread(() -> {
try {
service.closeBlocking();
} catch (InterruptedException e) {
LogHelper.error(e);
}
}));
}
static {