{"id":47637150,"url":"https://github.com/axi92/resleased","last_synced_at":"2026-04-02T00:22:29.400Z","repository":{"id":343503531,"uuid":"1177814529","full_name":"axi92/resleased","owner":"axi92","description":"A lightweight HTTP service for exclusive, time-bounded resource reservations. Designed for CI/CD pipelines and test frameworks that share hardware or services that can only be used by one job at a time.","archived":false,"fork":false,"pushed_at":"2026-03-10T17:38:20.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-10T21:53:47.517Z","etag":null,"topics":["ci-cd","devops","docker","docker-compose","golang","lease","lock-manager","resource-management","rest-api","self-hosted","testing"],"latest_commit_sha":null,"homepage":"https://hub.docker.com/r/axi92/resleased","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/axi92.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-10T11:57:31.000Z","updated_at":"2026-03-10T17:37:39.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/axi92/resleased","commit_stats":null,"previous_names":["axi92/resleased"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/axi92/resleased","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axi92%2Fresleased","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axi92%2Fresleased/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axi92%2Fresleased/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axi92%2Fresleased/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/axi92","download_url":"https://codeload.github.com/axi92/resleased/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/axi92%2Fresleased/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31293360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: 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":["ci-cd","devops","docker","docker-compose","golang","lease","lock-manager","resource-management","rest-api","self-hosted","testing"],"created_at":"2026-04-02T00:22:28.850Z","updated_at":"2026-04-02T00:22:29.378Z","avatar_url":"https://github.com/axi92.png","language":"Go","readme":"# resleased - Resource Lease Daemon\n\nA lightweight HTTP service for exclusive, time-bounded resource reservations.\nDesigned for CI/CD pipelines and test frameworks that share hardware or services\nthat can only be used by one job at a time.\n\n---\n\n## Concept\n\n| Term | Meaning |\n|------|---------|\n| **Resource** | Any unique ID (e.g. `X1`, `jtag-board-3`, `gpu-node-42`) |\n| **Lease** | An exclusive, time-bounded reservation of a resource |\n| **Token** | A secret returned on successful reservation - needed to extend or release |\n\n---\n\n## Build \u0026 Run\n\n```bash\n# Generate openapi docs\ngo run github.com/swaggo/swag/cmd/swag@latest init -g cmd/resleased/main.go -o internal/api/docs/\n\ngo build -o resleased ./cmd/resleased\n\n# defaults: listen :8080, state file ./resleased.json\n./resleased\n\n# custom options\n./resleased -addr :9090 -state /var/lib/resleased/state.json -purge-interval 1m\n```\n\n### Flags\n\n| Flag | Default | Description |\n|------|---------|-------------|\n| `-addr` | `:8080` | HTTP listen address |\n| `-state` | `resleased.json` | Path to JSON state file |\n| `-purge-interval` | `5m` | How often to clean expired leases from disk |\n\n---\n\n## API\n\n### Reserve a resource\n\n```\nPOST /api/v1/reserve\n```\n\n```json\n{ \"resource_id\": \"X1\", \"owner\": \"ci-job-42\", \"duration\": \"2h\" }\n```\n\n**Duration format**: Go duration strings - `30m`, `2h`, `1h30m`, `90s`.\n\n**200 OK** - resource is yours:\n```json\n{ \"token\": \"a3f9…\", \"expires_at\": \"2026-03-10T15:04:05Z\" }\n```\n\n**503 Service Unavailable** - resource is taken:\n```json\n{\n  \"error\": \"resource locked\",\n  \"owner\": \"ci-job-17\",\n  \"reserved_until\": \"2026-03-10T14:00:00Z\",\n  \"remaining_seconds\": 3547\n}\n```\n\n---\n\n### Extend a reservation\n\n```\nPOST /api/v1/extend\n```\n\n```json\n{ \"token\": \"a3f9…\", \"duration\": \"1h\" }\n```\n\n**200 OK**:\n```json\n{ \"expires_at\": \"2026-03-10T16:04:05Z\" }\n```\n\n**404** - unknown or expired token.\n\n---\n\n### Release a reservation\n\n```\nDELETE /api/v1/release\n```\n\n```json\n{ \"token\": \"a3f9…\" }\n```\n\n**200 OK**:\n```json\n{ \"released\": true }\n```\n\n---\n\n### Check resource status\n\n```\nGET /api/v1/status/{resource_id}\n```\n\n**200 OK** (available):\n```json\n{ \"available\": true }\n```\n\n**200 OK** (locked):\n```json\n{\n  \"available\": false,\n  \"owner\": \"ci-job-42\",\n  \"reserved_until\": \"2026-03-10T15:04:05Z\",\n  \"remaining_seconds\": 3547\n}\n```\n\n---\n\n## State file\n\nState is persisted to a JSON file so leases survive restarts.\nAll times are stored as **RFC3339 UTC timestamps** - no wall-clock tracking needed.\nOn startup, expired leases are silently discarded.\n\nExample `resleased.json`:\n```json\n{\n  \"reservations\": {\n    \"X1\": {\n      \"resource_id\": \"X1\",\n      \"owner\": \"ci-job-42\",\n      \"token\": \"a3f9c1d2e4b5...\",\n      \"expires_at\": \"2026-03-10T15:04:05Z\",\n      \"created_at\": \"2026-03-10T13:04:05Z\"\n    }\n  }\n}\n```\n\n---\n\n## Usage in a GitHub Actions / CI pipeline\n\n```yaml\n- name: Reserve hardware resource\n  id: lease\n  run: |\n    RESP=$(curl -sf -X POST http://resleased:8080/api/v1/reserve \\\n      -H 'Content-Type: application/json' \\\n      -d '{\"resource_id\":\"jtag-board-1\",\"owner\":\"${{ github.run_id }}\",\"duration\":\"1h\"}')\n    echo \"token=$(echo $RESP | jq -r .token)\" \u003e\u003e $GITHUB_OUTPUT\n\n- name: Run tests\n  run: make test-hardware\n\n- name: Release resource\n  if: always()\n  run: |\n    curl -sf -X DELETE http://resleased:8080/api/v1/release \\\n      -H 'Content-Type: application/json' \\\n      -d '{\"token\":\"${{ steps.lease.outputs.token }}\"}'\n```\n\n---\n\n## Compose\n\n```yaml\nservices:\n  resleased:\n    image: axi92/resleased:latest\n    container_name: resleased\n    restart: unless-stopped\n    ports:\n      - \"8080:8080\"\n    volumes:\n      - ./data:/data\n    #command:\n    #  - -addr=:8080\n    #  - -state=/data/state.json\n    #  - -purge-interval=5m\n```\n\n---\n\n## Systemd unit\n\n```ini\n[Unit]\nDescription=resleased resource lease daemon\nAfter=network.target\n\n[Service]\nExecStart=/usr/local/bin/resleased -addr :8080 -state /var/lib/resleased/state.json\nRestart=on-failure\nRestartSec=3\n\n[Install]\nWantedBy=multi-user.target\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxi92%2Fresleased","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxi92%2Fresleased","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxi92%2Fresleased/lists"}