use of org.jetbrains.io.BuiltInServer in project intellij-community by JetBrains.
the class BuildManager method startListening.
private int startListening() throws Exception {
EventLoopGroup group;
BuiltInServer mainServer = StartupUtil.getServer();
boolean isOwnEventLoopGroup = !Registry.is("compiler.shared.event.group", true) || mainServer == null || mainServer.getEventLoopGroup() instanceof OioEventLoopGroup;
if (isOwnEventLoopGroup) {
group = new NioEventLoopGroup(1, ConcurrencyUtil.newNamedThreadFactory("External compiler"));
} else {
group = mainServer.getEventLoopGroup();
}
final ServerBootstrap bootstrap = serverBootstrap(group);
bootstrap.childHandler(new ChannelInitializer() {
@Override
protected void initChannel(@NotNull Channel channel) throws Exception {
channel.pipeline().addLast(myChannelRegistrar, new ProtobufVarint32FrameDecoder(), new ProtobufDecoder(CmdlineRemoteProto.Message.getDefaultInstance()), new ProtobufVarint32LengthFieldPrepender(), new ProtobufEncoder(), myMessageDispatcher);
}
});
Channel serverChannel = bootstrap.bind(InetAddress.getLoopbackAddress(), 0).syncUninterruptibly().channel();
myChannelRegistrar.setServerChannel(serverChannel, isOwnEventLoopGroup);
return ((InetSocketAddress) serverChannel.localAddress()).getPort();
}
use of org.jetbrains.io.BuiltInServer in project intellij-community by JetBrains.
the class BuiltInServerManagerImpl method startServerInPooledThread.
private Future<?> startServerInPooledThread() {
if (!started.compareAndSet(false, true)) {
return null;
}
return ApplicationManager.getApplication().executeOnPooledThread(() -> {
try {
BuiltInServer mainServer = StartupUtil.getServer();
if (mainServer == null || mainServer.getEventLoopGroup() instanceof OioEventLoopGroup) {
server = BuiltInServer.start(1, getDefaultPort(), PORTS_COUNT, false, null);
} else {
server = BuiltInServer.start(mainServer.getEventLoopGroup(), false, getDefaultPort(), PORTS_COUNT, true, null);
}
bindCustomPorts(server);
} catch (Throwable e) {
LOG.info(e);
NOTIFICATION_GROUP.getValue().createNotification("Cannot start internal HTTP server. Git integration, JavaScript debugger and LiveEdit may operate with errors. " + "Please check your firewall settings and restart " + ApplicationNamesInfo.getInstance().getFullProductName(), NotificationType.ERROR).notify(null);
return;
}
LOG.info("built-in server started, port " + server.getPort());
Disposer.register(ApplicationManager.getApplication(), server);
});
}
use of org.jetbrains.io.BuiltInServer in project intellij-community by JetBrains.
the class SocketLock method dispose.
public void dispose() {
log("enter: dispose()");
BuiltInServer server = myServer;
if (server == null)
return;
try {
Disposer.dispose(server);
} finally {
try {
underLocks(() -> {
FileUtil.delete(new File(myConfigPath, PORT_FILE));
FileUtil.delete(new File(mySystemPath, PORT_FILE));
FileUtil.delete(new File(mySystemPath, TOKEN_FILE));
return null;
});
} catch (Exception e) {
Logger.getInstance(SocketLock.class).warn(e);
}
}
}
Aggregations