Skip to content

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).

Tips

  • In BSD/Unix-like systems, SWS will start the graceful shutdown process when a SIGTERM, SIGINT or SIGQUIT termination signal is caught.
  • In Windows systems otherwise, SWS will start the graceful shutdown process right after a CTRL + C. 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

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.

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