提交 48932ae2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Server tool: when starting one service fails, the started services are now stopped.

上级 dd477e58
...@@ -206,39 +206,45 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -206,39 +206,45 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
out.println("Shutting down TCP Server at " + tcpShutdownServer); out.println("Shutting down TCP Server at " + tcpShutdownServer);
shutdownTcpServer(tcpShutdownServer, tcpPassword, tcpShutdownForce, false); shutdownTcpServer(tcpShutdownServer, tcpPassword, tcpShutdownForce, false);
} }
if (webStart) { try {
web = createWebServer(args); if (webStart) {
web.setShutdownHandler(this); web = createWebServer(args);
SQLException result = null; web.setShutdownHandler(this);
try { SQLException result = null;
web.start();
} catch (Exception e) {
result = DbException.toSQLException(e);
}
out.println(web.getStatus());
// start browser in any case (even if the server is already running)
// because some people don't look at the output,
// but are wondering why nothing happens
if (browserStart) {
try { try {
openBrowser(web.getURL()); web.start();
} catch (Exception e) { } catch (Exception e) {
out.println(e.getMessage()); result = DbException.toSQLException(e);
}
out.println(web.getStatus());
// start browser in any case (even if the server is already running)
// because some people don't look at the output,
// but are wondering why nothing happens
if (browserStart) {
try {
openBrowser(web.getURL());
} catch (Exception e) {
out.println(e.getMessage());
}
}
if (result != null) {
throw result;
} }
} }
if (result != null) { if (tcpStart) {
throw result; tcp = createTcpServer(args);
tcp.start();
out.println(tcp.getStatus());
tcp.setShutdownHandler(this);
} }
} if (pgStart) {
if (tcpStart) { pg = createPgServer(args);
tcp = createTcpServer(args); pg.start();
tcp.start(); out.println(pg.getStatus());
out.println(tcp.getStatus()); }
} } catch (SQLException e) {
if (pgStart) { stopAll();
pg = createPgServer(args); throw e;
pg.start();
out.println(pg.getStatus());
} }
} }
...@@ -324,7 +330,10 @@ public class Server extends Tool implements Runnable, ShutdownHandler { ...@@ -324,7 +330,10 @@ public class Server extends Tool implements Runnable, ShutdownHandler {
* @return the server * @return the server
*/ */
public static Server createTcpServer(String... args) throws SQLException { public static Server createTcpServer(String... args) throws SQLException {
return new Server(new TcpServer(), args); TcpServer service = new TcpServer();
Server server = new Server(service, args);
service.setShutdownHandler(server);
return server;
} }
/** /**
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论