This is the Graceful Shutdown sample code in Go, feel free to learn.
go run main.go
- Run the service
- Open the other terminal, request to the API using this command line
curl -X GET http://localhost:8081/api/v1/test-graceful-shutdown
- Back to the service terminal Stop the service
Ctrl + C
- Waiting the response from api
https://anhlamweb.com/bai-viet-75/tim-hieu-ve-graceful-shutdown-graceful-shutdown-trong-golang.html