2020-01-31 13:10:56 +01:00
|
|
|
# shutdown-server
|
2020-01-26 00:49:19 +01:00
|
|
|
|
2020-01-31 13:10:56 +01:00
|
|
|
Demonstrates how to shutdown the web server in a couple of ways:
|
|
|
|
|
2022-08-08 00:58:56 +02:00
|
|
|
1. remotely, via HTTP request
|
2022-02-06 09:13:24 +01:00
|
|
|
1. sending a SIGINT signal to the server (control-c)
|
2022-08-08 00:58:56 +02:00
|
|
|
- Actix Web servers support shutdown signals by default. [See here for more info.](https://actix.rs/docs/server#graceful-shutdown)
|
2020-01-26 00:49:19 +01:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Running The Server
|
|
|
|
|
2022-08-08 00:58:56 +02:00
|
|
|
```console
|
|
|
|
$ cd shutdown-server
|
|
|
|
$ cargo run --bin shutdown-server
|
|
|
|
[INFO] starting HTTP server at http://localhost:8080
|
|
|
|
[INFO] Starting 2 workers
|
|
|
|
[INFO] Actix runtime found; starting in Actix runtime
|
2020-01-26 00:49:19 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
### Available Routes
|
|
|
|
|
2022-08-08 00:58:56 +02:00
|
|
|
- [`GET /hello`](http://localhost:8080/hello)
|
|
|
|
- Test hello world
|
|
|
|
- `POST /stop/true`
|
|
|
|
- Gracefully shuts down the server and exit
|
|
|
|
- `POST /stop/false`
|
|
|
|
- Forces server shutdown and exits
|