Alert when we cannot bind
This commit is contained in:
parent
ce7c095243
commit
49a22f188f
@ -9,6 +9,8 @@ import com.ning.http.client.providers.netty.NettyAsyncHttpProviderConfig;
|
|||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import io.netty.channel.ChannelException;
|
import io.netty.channel.ChannelException;
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.MultithreadEventLoopGroup;
|
import io.netty.channel.MultithreadEventLoopGroup;
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
import io.netty.channel.socket.nio.NioServerSocketChannel;
|
||||||
@ -218,18 +220,29 @@ public class BungeeCord extends ProxyServer
|
|||||||
|
|
||||||
public void startListeners()
|
public void startListeners()
|
||||||
{
|
{
|
||||||
for ( ListenerInfo info : config.getListeners() )
|
for ( final ListenerInfo info : config.getListeners() )
|
||||||
{
|
{
|
||||||
Channel server = new ServerBootstrap()
|
new ServerBootstrap()
|
||||||
.channel( NioServerSocketChannel.class )
|
.channel( NioServerSocketChannel.class )
|
||||||
.childAttr( PipelineUtils.LISTENER, info )
|
.childAttr( PipelineUtils.LISTENER, info )
|
||||||
.childHandler( PipelineUtils.SERVER_CHILD )
|
.childHandler( PipelineUtils.SERVER_CHILD )
|
||||||
.group( eventLoops )
|
.group( eventLoops )
|
||||||
.localAddress( info.getHost() )
|
.localAddress( info.getHost() )
|
||||||
.bind().channel();
|
.bind().addListener( new ChannelFutureListener()
|
||||||
listeners.add( server );
|
{
|
||||||
|
@Override
|
||||||
getLogger().info( "Listening on " + info.getHost() );
|
public void operationComplete(ChannelFuture future) throws Exception
|
||||||
|
{
|
||||||
|
if ( future.isSuccess() )
|
||||||
|
{
|
||||||
|
listeners.add( future.channel() );
|
||||||
|
getLogger().info( "Listening on " + info.getHost() );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
getLogger().log( Level.WARNING, "Could not bind to host " + info.getHost(), future.cause() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user