B
B
Bobarev2013-10-23 17:54:03
Java
Bobarev, 2013-10-23 17:54:03

How to properly stop Netty 4 in NetBeans 7.4?

The Stop command in NetBeans fails to gracefully stop Netty .
addShutdownHook - does not respond to Stop in the IDE.
Of course, you can write a shutdown handler for Netty itself, but in Eclipse, for example, everything works fine without addShutdownHook.
I spent almost the whole day today looking for an answer, but I did not find anything.

public class App{

    public static void init() {
        Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
          System.out.println("Try shutdown ...");
        }
      });
    }
    
    public static void main(String[] args) throws Exception {
        int port;
        init();
        if (args.length > 0) {
            port = Integer.parseInt(args[0]);
        } else {
            port = 8084;
        }
        System.out.println("Try start server at port : " + port);
        new NettyServer(port).run();
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question