{"id":15587557,"url":"https://github.com/icyleaf/nomad-invalid-services-cleaner","last_synced_at":"2026-02-19T17:01:00.027Z","repository":{"id":185067018,"uuid":"672951693","full_name":"icyleaf/nomad-invalid-services-cleaner","owner":"icyleaf","description":"Auto clean all invalid zombie nomad service(s)","archived":false,"fork":false,"pushed_at":"2025-03-19T12:46:35.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-24T04:48:57.034Z","etag":null,"topics":["devops","hashicorp","hashicorp-nomad"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/icyleaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-31T14:30:07.000Z","updated_at":"2025-03-19T12:45:43.000Z","dependencies_parsed_at":"2025-02-20T04:24:04.716Z","dependency_job_id":"6f3f16a5-c32c-4dba-96ac-f34225898abe","html_url":"https://github.com/icyleaf/nomad-invalid-services-cleaner","commit_stats":null,"previous_names":["icyleaf/nomad-invalid-services-cleaner"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/icyleaf/nomad-invalid-services-cleaner","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyleaf%2Fnomad-invalid-services-cleaner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyleaf%2Fnomad-invalid-services-cleaner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyleaf%2Fnomad-invalid-services-cleaner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyleaf%2Fnomad-invalid-services-cleaner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icyleaf","download_url":"https://codeload.github.com/icyleaf/nomad-invalid-services-cleaner/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icyleaf%2Fnomad-invalid-services-cleaner/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29623546,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T13:04:20.082Z","status":"ssl_error","status_checked_at":"2026-02-19T13:03:33.775Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":["devops","hashicorp","hashicorp-nomad"],"created_at":"2024-10-02T22:02:12.188Z","updated_at":"2026-02-19T17:00:59.992Z","avatar_url":"https://github.com/icyleaf.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nomad Invalid Services Cleaner\n\nIf you are using nomad to run your services, you can use this script to be done:\n\n1. clean up invalid(zombie) services.\n1. restart missing empty service(s) on running jobs.\n\n## Usage\n\n### Docker\n\n```bash\ndocker run -d --name nomad-invalid-services-cleaner:0.1 \\\n  -e NOMAD_ENDPOINT=http://172.16.11.231 \\\n  -e NOMAD_VERSION=v1 \\\n  -e NOMAD_TOKEN=secret_token \\\n  -e NOMAD_RUNNER_INTERVAL=3600 \\\n  -e LOGGER_LEVEL=info \\\n  gchr.io/icyleaf/nomad-invalid-services-cleaner\n```\n\n### Nomad\n\n#### Schedule run\n\n```hcl\njob \"nomad-invalid-services-cleaner\" {\n  type        = \"batch\"\n\n  periodic {\n    prohibit_overlap  = true\n    cron              = \"0/10 * * * * *\"\n    time_zone         = \"Asia/Shanghai\"\n  }\n\n  group \"services_cleaner\" {\n    task \"cleaner\" {\n      driver = \"docker\"\n\n      config {\n        image = \"ghcr.io/icyleaf/nomad-invalid-services-cleaner:0.1\"\n      }\n\n      template {\n        destination = \"secrets/.env\"\n        env         = true\n        data        = \u003c\u003c-EOF\n        ONESHOT         = true\n\n        NOMAD_ENDPOINT  = http://{{ env \"attr.unique.network.ip-address\" }}:4646\n\n        {{- with nomadVar \"nomad/jobs/nomad-invalid-services-cleaner\" }}\n        NOMAD_TOKEN = {{ .nomad_token }}\n        {{- end}}\n        EOF\n      }\n\n      resources {\n        cpu     = 50\n        memory  = 50\n      }\n    }\n  }\n}\n```\n\n#### Long loop run\n\n```hcl\njob \"nomad-invalid-services-cleaner\" {\n  type        = \"service\"\n\n  group \"services_cleaner\" {\n    task \"cleaner\" {\n      driver = \"docker\"\n\n      config {\n        image = \"ghcr.io/icyleaf/nomad-invalid-services-cleaner:0.1\"\n      }\n\n      template {\n        destination = \"secrets/.env\"\n        env         = true\n        data        = \u003c\u003c-EOF\n        NOMAD_ENDPOINT  = http://{{ env \"attr.unique.network.ip-address\" }}:4646\n\n        {{- with nomadVar \"nomad/jobs/nomad-invalid-services-cleaner\" }}\n        NOMAD_TOKEN = {{ .nomad_token }}\n        {{- end}}\n        EOF\n      }\n\n      resources {\n        cpu     = 50\n        memory  = 50\n      }\n    }\n  }\n}\n```\n\n## Output\n\n### All good\n\n```\nI, [2023-07-31T11:50:41.151197 #1]  INFO -- : Starting nomad invalid services runner ...\nI, [2023-07-31T11:50:41.176254 #1]  INFO -- : Found 57 services in namespace: default\nI, [2023-07-31T11:50:41.357723 #1]  INFO -- : All services is good!\n```\n\n### Found issue\n\n```\nI, [2023-07-31T11:50:41.151197 #1]  INFO -- : Starting nomad invalid services runner ...\nI, [2023-07-31T11:50:41.176254 #1]  INFO -- : Found 57 services in namespace: default\nI, [2023-07-31T11:50:52.211327 #1]  INFO -- : Deleted invalid service sample-service (_nomad-task-4cb7a77c-d98e-8586-fef0-892000445f84-group-sample-service-web)\nI, [2023-07-31T11:51:00.357723 #1]  INFO -- : Found 1 invalid services to clean up: sample-service\n```\n\n## Environments\n\n- NOMAD_ENDPOINT: `http://127.0.0.1`\n- NOMAD_VERSION: `v1` (default is `v1`)\n- NOMAD_TOKEN: `inserct-token`\n- NOMAD_API_TIMEOUT: `30` (default is `30`)\n- NOMAD_RUNNER_INTERVAL: `3600`\n- LOGGER_LEVEL: `error/info/debug`\n- NOMAD_IGNORE_RESTART_EMPTY_SERVICES: `true/false` (default is `false`)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficyleaf%2Fnomad-invalid-services-cleaner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficyleaf%2Fnomad-invalid-services-cleaner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficyleaf%2Fnomad-invalid-services-cleaner/lists"}