Skip to content

Commit 065155d

Browse files
committed
Update the namespace for Mode class.
1 parent b8f6578 commit 065155d

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/main/java/org/tinystruct/system/HttpProxyServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public String version() {
4444
@Argument(key = "server-port", description = "Server port"),
4545
@Argument(key = "remote-server-host", description = "Remote Server host"),
4646
@Argument(key = "remote-server-port", description = "Remote Server port"),
47-
}, example = "bin/dispatcher start --import org.tinystruct.system.RedisProxyServer --server-port 8080", mode = org.tinystruct.application.Action.Mode.CLI)
47+
}, example = "bin/dispatcher start --import org.tinystruct.system.RedisProxyServer --server-port 8080", mode = Action.Mode.CLI)
4848
@Override
4949
public void start() throws ApplicationException {
5050
if (getContext() != null) {

src/main/java/org/tinystruct/system/NettyHttpServer.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public String version() {
100100
@Argument(key = "https.proxyPort", description = "Proxy port for https"),
101101
@Argument(key = "logging.enabled", description = "Enable Netty logging (default: false)"),
102102
@Argument(key = "logging.level", description = "Netty logging level (TRACE, DEBUG, INFO, WARN, ERROR) (default: INFO)")
103-
}, example = "bin/dispatcher start --import org.tinystruct.system.NettyHttpServer --server-port 777", mode = org.tinystruct.application.Action.Mode.CLI)
103+
}, example = "bin/dispatcher start --import org.tinystruct.system.NettyHttpServer --server-port 777", mode = Action.Mode.CLI)
104104
@Override
105105
public void start() throws ApplicationException {
106106

@@ -129,7 +129,7 @@ public void start() throws ApplicationException {
129129
}
130130
}
131131

132-
System.out.println(ApplicationManager.call("--logo", null, org.tinystruct.application.Action.Mode.CLI));
132+
System.out.println(ApplicationManager.call("--logo", null, Action.Mode.CLI));
133133

134134
String charsetName = null;
135135
Settings settings = new Settings();
@@ -195,7 +195,16 @@ public void initChannel(SocketChannel ch) {
195195

196196
// Open the default browser
197197
getContext().setAttribute("--url", "http://localhost:" + this.port);
198-
ApplicationManager.call("open", getContext(), org.tinystruct.application.Action.Mode.CLI);
198+
ApplicationManager.call("open", getContext(), Action.Mode.CLI);
199+
200+
// Keep the server running
201+
logger.info("Server is running. Press Ctrl+C to stop.");
202+
203+
// Add shutdown hook
204+
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
205+
logger.info("Shutting down HTTP server...");
206+
stop();
207+
}));
199208

200209
// Wait until the server socket is closed.
201210
future.channel().closeFuture().sync();

0 commit comments

Comments
 (0)