@@ -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