List of usage examples for io.netty.handler.logging LogLevel INFO
LogLevel INFO
To view the source code for io.netty.handler.logging LogLevel INFO.
Click Source Link
From source file:uidserver.UIDServer.java
/** * @param args the command line arguments */// w w w. jav a 2 s . co m public static void main(String[] args) throws Exception { if (args.length == 1) { if (args[0].toLowerCase().contains("help")) { System.out.println("This script can only run in Java 1.8"); System.out.println("java -jar ./UIDServer.jar " + "./config.xml"); System.exit(0); } else { new Config(args[0]); } } else { new Config("D:/projects/UIDTest/server/config.xml"); } new UIDGenerator(); final int PORT = Integer.parseInt(System.getProperty("port", Config.port)); SelfSignedCertificate ssc = new SelfSignedCertificate(); SslContext sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new UIDServerInitializer(sslCtx)); b.bind(PORT).sync().channel().closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:websocketx.server.WebSocketServer.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure SSL. final SslContext sslCtx; if (SSL) {//from w w w. j ava2 s.co m SelfSignedCertificate ssc = new SelfSignedCertificate(); sslCtx = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build(); } else { sslCtx = null; } new Thread(new Runnable() { public void run() { while (true) { try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("channelGroup:" + WebSocketFrameHandler.channelGroup); System.out.println("channelGroup.isEmpty():" + WebSocketFrameHandler.channelGroup.isEmpty()); System.out.println("channelGroupMap:" + WebSocketFrameHandler.channelGroupMap); } } }).start(); EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGroup workerGroup = new NioEventLoopGroup(); try { ServerBootstrap b = new ServerBootstrap(); b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new WebSocketServerInitializer(sslCtx)); Channel ch = b.bind(PORT).sync().channel(); System.out.println("Open your web browser and navigate to " + (SSL ? "https" : "http") + "://127.0.0.1:" + PORT + '/'); ch.closeFuture().sync(); } finally { bossGroup.shutdownGracefully(); workerGroup.shutdownGracefully(); } }
From source file:zjsx.flowlight.netty.TcpServer.java
License:Apache License
public void startService(final ServerListener serverListener) { mBootstrap = new ServerBootstrap(); bossGroup = new NioEventLoopGroup(1); workerGroup = new NioEventLoopGroup(); mBootstrap.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class) .handler(new LoggingHandler(LogLevel.INFO)).childHandler(new TcpServerInitializer()); mChannel = mBootstrap.bind(PORT).addListener(new ChannelFutureListener() { @Override//from w w w . j a v a2 s. com public void operationComplete(ChannelFuture future) throws Exception { if (serverListener != null) serverListener.onLaunchFinished(future.isSuccess()); if (future.isSuccess()) { launched = true; System.out.println("TCPServer Launch Success"); } else { System.err.print("TCPServer Launch Failed"); } } }).channel(); }