From cc9982d5cc02c35c02dd1a6de2f846140f78695f Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Wed, 11 Dec 2024 14:59:23 +0330 Subject: [PATCH 1/2] graceful shutdown and sbt. --- docs/reference/server.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/reference/server.md b/docs/reference/server.md index e65abc4456..2faa06822c 100644 --- a/docs/reference/server.md +++ b/docs/reference/server.md @@ -566,6 +566,12 @@ printSource("zio-http-example/src/main/scala/example/GracefulShutdown.scala") This approach ensures that clients receive appropriate responses for their requests, rather than encountering errors or abrupt disconnections. It helps maintain the integrity of the communication between clients and the server, providing a smoother experience for users and preventing potential data loss or corruption. +:::Note +When running a server through SBT, pressing Ctrl+C doesn't cleanly shut down the application. Instead, SBT intercepts the signal and throws a `java.lang.InterruptedException`, bypassing any custom shutdown handlers you may have implemented. + +However, if you run the same server directly from a packaged JAR file using `java -jar`, Ctrl+C will trigger the expected graceful shutdown sequence, allowing your application to clean up resources properly before terminating. +::: + ## Idle Timeout Configuration The idle timeout is a mechanism by which the server automatically terminates an inactive connection after a certain period of inactivity. When a client connects to the server, it establishes a connection to request and receive responses. However, there may be instances where the client becomes slow, inactive, or unresponsive, and the server needs to reclaim resources associated with idle connections to optimize server performance and resource utilization. From a96af017f4bd3389fd0cef8965b5288625b5a2bb Mon Sep 17 00:00:00 2001 From: Milad Khajavi Date: Wed, 11 Dec 2024 15:07:24 +0330 Subject: [PATCH 2/2] title --- docs/reference/server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/server.md b/docs/reference/server.md index 2faa06822c..61b619b642 100644 --- a/docs/reference/server.md +++ b/docs/reference/server.md @@ -44,7 +44,7 @@ Server.serve(routes).provide( ) ``` -:::note +:::note[Handling Interrupt Signals (Ctrl+C) in SBT] Sometimes we may want to have more control over installation of the http application into the server. In such cases, we may want to use the `Server.install` method. This method only installs the `Routes` into the server, and the lifecycle of the server can be managed separately. :::