添加端口被占用时的提示说明

This commit is contained in:
imhao183
2021-01-30 09:17:57 +08:00
parent b4979e5408
commit 3a0653b8ed
3 changed files with 19 additions and 12 deletions
@@ -149,12 +149,10 @@ public class NettyAcceptor implements ServerAcceptor {
} catch (InterruptedException ex) {
LOG.error("An interruptedException was caught while initializing server. Protocol={}", protocol, ex);
} catch (Exception e) {
if(e instanceof BindException) {
e.printStackTrace();
LOG.error("端口 {} 已经被占用。请检查该端口被那个程序占用,找到程序停掉。\n查找端口被那个程序占用的命令是: netstat -tunlp | grep {}", port, port);
System.out.println("端口 " + port + " 已经被占用。请检查该端口被那个程序占用,找到程序停掉。\n查找端口被那个程序占用的命令是: netstat -tunlp | grep " + port);
}
throw e;
e.printStackTrace();
LOG.error("端口 {} 已经被占用。请检查该端口被那个程序占用,找到程序停掉。\n查找端口被那个程序占用的命令是: netstat -tunlp | grep {}", port, port);
System.out.println("端口 " + port + " 已经被占用。请检查该端口被那个程序占用,找到程序停掉。\n查找端口被那个程序占用的命令是: netstat -tunlp | grep " + port);
System.exit(-1);
}
}