{"id":20900559,"url":"https://github.com/dataphos/lib-shutdown","last_synced_at":"2026-05-26T17:33:29.517Z","repository":{"id":257809066,"uuid":"866445172","full_name":"dataphos/lib-shutdown","owner":"dataphos","description":"A lightweight Go library which offers utility functions that deal with graceful termination on selected OS signals.","archived":false,"fork":false,"pushed_at":"2024-10-11T09:19:38.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-26T06:47:49.296Z","etag":null,"topics":["go","library"],"latest_commit_sha":null,"homepage":"","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/dataphos.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-02T09:19:27.000Z","updated_at":"2024-10-11T14:43:42.000Z","dependencies_parsed_at":"2024-10-04T06:41:43.461Z","dependency_job_id":"5ba5fac2-5b11-4b85-8205-7305ac51ff6e","html_url":"https://github.com/dataphos/lib-shutdown","commit_stats":null,"previous_names":["dataphos/lib-shutdown"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dataphos/lib-shutdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataphos%2Flib-shutdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataphos%2Flib-shutdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataphos%2Flib-shutdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataphos%2Flib-shutdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dataphos","download_url":"https://codeload.github.com/dataphos/lib-shutdown/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dataphos%2Flib-shutdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33532132,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"ssl_error","status_checked_at":"2026-05-26T15:22:15.568Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","library"],"created_at":"2024-11-18T11:20:43.818Z","updated_at":"2026-05-26T17:33:29.502Z","avatar_url":"https://github.com/dataphos.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lib-shutdown\n\nlib-shutdown is a lightweight Go library that offers utility functions that deal with graceful termination on selected\nOS signals.\n\n## Installation\n\n`go get github.com/dataphos/lib-shutdown`\n\n## Getting Started\n\n### Cancelling Context On OS Signals\n\nThe code snippet below shows the basic principle of the `graceful` package:\n\n```go\nsecondsRemaining := 10\nctx, cancel := context.WithTimeout(context.Background(), time.Duration(secondsRemaining)*time.Second)\ndefer cancel()\n\nctx = graceful.WithSignalShutdown(ctx)\n\nfor {\n    select {\n    case \u003c-ctx.Done():\n        fmt.Println(\"context cancelled, leaving\")\n        return\n    case \u003c-time.After(1 * time.Second):\n        secondsRemaining -= 1\n        fmt.Println(secondsRemaining, \"seconds remaining\")\n    }\n}\n```\n\n`graceful.WithSignalShutdown` returns a new ctx derived from the one given, which will be cancelled when this process\nreceives a SIGTERM or SIGQUIT signal, cancelling the returned context before the parent context times out.\n\n### Graceful Shutdown of HTTP Servers\n\n`graceful.ListenAndServe` and `graceful.ListenAndServeTLS` functions wrap the equivalent\nmethod of the given `http.Server` instance, signaling to the server that a SIGTERM or SIGQUIT signal\nwas received, allowing some additional time for the server to cleanup and complete the active requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataphos%2Flib-shutdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdataphos%2Flib-shutdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdataphos%2Flib-shutdown/lists"}