Files
static-web-server/docs/content/features/graceful-shutdown.md
Matthias Schoettle dd43d06551 refactor: format check support Markdown files via mdformat (#597)
* chore: format Markdown files with mdformat
* chore: switch to mdformat config file
* chore: add missing trailing slash
* docs: add section about formatting Markdown files
2025-12-07 10:40:21 +01:00

1.7 KiB

Graceful Shutdown

SWS can terminate gracefully in what is known as a graceful shutdown process.

It means that when a SIGTERM termination signal is caught the server will stop receiving more requests immediately but in turn, it will continue processing all existing requests until they are completed (or closed).

!!! tip "Tips"

- In **BSD/Unix-like** systems, SWS will start the graceful shutdown process when a `SIGTERM`, `SIGINT` or `SIGQUIT` [termination signal](https://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html) is caught.
- In **Windows** systems otherwise, SWS will start the graceful shutdown process right after a <kbd>CTRL + C</kbd>. This is used to abort the current task.

Grace Period

Sometimes one wants to control the graceful shutdown process for different reasons. For example during Kubernetes rollouts.

In these situations, SWS allows delaying the graceful shutdown process right after a SIGTERM providing a grace period in seconds.

The feature is disabled by default and can be controlled by the numeric -q, --grace-period option or its equivalent SERVER_GRACE_PERIOD env.

!!! tip "Tip"

The maximum grace period value is `255` seconds (4.25 min). The default value is `0` (no delay).

Here is an example of delaying the graceful shutdown process by 10 seconds after a SIGTERM.

static-web-server -p 8787 -d ./public/ -g trace --grace-period 10