{"id":18418617,"url":"https://github.com/bsm/shutdown","last_synced_at":"2025-04-07T13:31:20.906Z","repository":{"id":51047067,"uuid":"57061806","full_name":"bsm/shutdown","owner":"bsm","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-25T15:43:01.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T19:02:36.774Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-25T17:28:11.000Z","updated_at":"2021-05-25T15:42:40.000Z","dependencies_parsed_at":"2022-09-11T12:21:26.814Z","dependency_job_id":null,"html_url":"https://github.com/bsm/shutdown","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fshutdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fshutdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fshutdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsm%2Fshutdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsm","download_url":"https://codeload.github.com/bsm/shutdown/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247661669,"owners_count":20975096,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T04:14:09.087Z","updated_at":"2025-04-07T13:31:20.640Z","avatar_url":"https://github.com/bsm.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shutdown\n\n[![GoDoc](https://godoc.org/github.com/bsm/shutdown?status.png)](http://godoc.org/github.com/bsm/shutdown)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nWait for servers to terminate gracefully.\n\n## Example:\n\n```go\nimport (\n\t\"context\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t\"github.com/bsm/shutdown\"\n)\n\nfunc main() {\n\tsrv := \u0026http.Server{\n\t\tAddr:\t\t\":8080\",\n\t\tHandler:\thttp.FileServer(http.Dir(\"/usr/share/doc\")),\n\t}\n\n\t// Wait for either SIGINT/SIGTERM or ListenAndServe to exit.\n\t// Handle errors.\n\terr := shutdown.Wait(srv.ListenAndServe)\n\tif err != nil \u0026\u0026 err != http.ErrServerClosed {\n\t\tlog.Fatalln(\"Server error\", err)\n\t}\n\n\t// Perform a graceful server shutdown.\n\tlog.Println(\"Shutting down ...\")\n\ttimeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\n\tdefer cancel()\n\n\tif err := srv.Shutdown(timeoutCtx); err != nil {\n\t\tlog.Println(\"Shutdown error\", err)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fshutdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsm%2Fshutdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsm%2Fshutdown/lists"}