{"id":23008097,"url":"https://github.com/sagarrakshe/nomad-dtree","last_synced_at":"2026-03-13T19:04:55.743Z","repository":{"id":143235412,"uuid":"234021736","full_name":"sagarrakshe/nomad-dtree","owner":"sagarrakshe","description":"Tool to handle dependencies between nomad jobs","archived":false,"fork":false,"pushed_at":"2023-06-09T10:50:10.000Z","size":58,"stargazers_count":52,"open_issues_count":5,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-19T04:06:00.549Z","etag":null,"topics":["consul","golang","hashicorp","nomad","nomad-dtree","nomad-jobs"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagarrakshe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2020-01-15T07:18:12.000Z","updated_at":"2025-11-30T17:10:04.000Z","dependencies_parsed_at":"2024-06-20T01:39:35.408Z","dependency_job_id":null,"html_url":"https://github.com/sagarrakshe/nomad-dtree","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sagarrakshe/nomad-dtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagarrakshe%2Fnomad-dtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagarrakshe%2Fnomad-dtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagarrakshe%2Fnomad-dtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagarrakshe%2Fnomad-dtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagarrakshe","download_url":"https://codeload.github.com/sagarrakshe/nomad-dtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagarrakshe%2Fnomad-dtree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30472988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-13T17:15:31.527Z","status":"ssl_error","status_checked_at":"2026-03-13T17:15:22.394Z","response_time":60,"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":["consul","golang","hashicorp","nomad","nomad-dtree","nomad-jobs"],"created_at":"2024-12-15T09:00:43.542Z","updated_at":"2026-03-13T19:04:55.704Z","avatar_url":"https://github.com/sagarrakshe.png","language":"Go","funding_links":[],"categories":["Infrastructure setup"],"sub_categories":["Automation and Infrastructure Management"],"readme":"\nnomad-dtree\n===========\n\n[![Build Status](https://travis-ci.com/sagarrakshe/nomad-dtree.png?branch=master)](https://travis-ci.com/sagarrakshe/nomad-dtree)\n\nNomad doesn't have its own dependency management plugin between the jobs. \nEspecially with rise in the microservices pattern, it becomes difficult to maintain order of deployment using Nomad.\nFor eg. Database service must be up before the api service is started.\nThe order of deployment of the jobs has to be handled separately, using some external tool like Rundeck.\n\nNomad also lacks feature of post/pre hook. (Check issue: [https://github.com/hashicorp/nomad/issues/419](https://github.com/hashicorp/nomad/issues/419) and [https://github.com/hashicorp/nomad/issues/2851](https://github.com/hashicorp/nomad/issues/2851)).\nMany of services a pre-setup step or a post setup.\nFor example, when we run a postgres or any db container, we need to create a user, db and grant permissions.\nAnother example, on bringing up a rabbitmq cluster we might need to create vhost, user etc.\n\n**nomad-dtree** is an attempt to address these problems.\n\nnomad-dtree expects everything to be a nomad job. Even a post/pre hook should be a nomad jobs.\nIt also expects a JSON where the dependency is mentioned.\n\n\nHow it works\n=============\n\nConsider a small service which has three components:\n\n- nginx\n- api\n- postgres\n\nThe order of dependency is same as above. The postgres service has a post hook, a\nsmall step of creating a user and db which is used by the api service. So we have\nnomad jobs:\n\n- nginx.nomad\n- api.nomad\n- postgres.nomad\n- postgres_setup.nomad\n\nThe dependency file for the above servcies is as follows:\n\n```json\n{\n  \"dependencies\": {\n    \"nginx\": {\n      \"wait_cond\": 5,\n      \"pre\": {\n        \"job\": \"api\"\n      }\n    },\n    \"api\": {\n      \"wait_cond\": 7,\n      \"pre\": {\n        \"job\": \"postgres\"\n      }\n    },\n    \"postgres\": {\n      \"post\": {\n        \"job\": \"postgres_setup\",\n        \"wait_cond\": 3\n      },\n      \"wait_cond\": 5\n    }\n  }\n}\n```\n\nNow, each block in the `dependencies` json denotes a nomad job. It has three\nparts, consider `api`:\n\n```json\n    \"api\": {\n      \"wait_cond\": 7,\n      \"pre\": {\n        \"job\": \"postgres\"\n      }\n    },\n```\n\n- **wait_cond** (required) - It the wait_time, time taken for the api service to be healthy. \n- **pre** (optional) - Pre-requisite job that has to be done before running the api, in this case postgres should be running before running postgres.\n- **post**(optional) - Post hook, job that needs to be run after api is running (and after waiting for `wait_cond` seconds).\n\nNow, when we run the following command:\n\n```\nnomad-dtree \\\n  run \\\n  --job nginx \\  (note we are submitting nginx job here)\n  --server-addr \u003cnomad-address\u003e \\\n  --store filesystem \\\n  --fs-depfile-path \u003cpath to dependency json file\u003e \\\n  --fs-jobs-path \u003cpath to directory containing all nomad jobs\u003e\n```\n\nThe order of execution will be as follows:\n\n```\npostgres.nomad -\u003e postgres_setup.nomad -\u003e api.nomad -\u003e nginx.nomad\n```\n\nSimilar to `run` you can also `stop` the jobs.\nStop command has two flags:\n\n- **purge** (optional): When used, Job will be purged from the system.\n- **deep** (optional): When used, the mentioned job and all the dependent child jobs will be stopped.\n\n```\nnomad-dtree \\\n  stop --purge --deep \\\n  --server-addr \u003cnomad-address\u003e \\\n  --store filesystem \\\n  --fs-depfile-path \u003cpath to dependency json file\u003e \\\n  --fs-jobs-path \u003cpath to directory containing all nomad jobs\u003e\n```\n\nFor more examples check [Examples](https://github.com/sagarrakshe/nomad-dtree/tree/master/examples)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagarrakshe%2Fnomad-dtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagarrakshe%2Fnomad-dtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagarrakshe%2Fnomad-dtree/lists"}