{"id":21659166,"url":"https://github.com/pnxtech/hydra-cli","last_synced_at":"2025-04-11T04:06:08.652Z","repository":{"id":54675802,"uuid":"65032597","full_name":"pnxtech/hydra-cli","owner":"pnxtech","description":"Hydra Command Line Client","archived":false,"fork":false,"pushed_at":"2020-11-23T17:03:45.000Z","size":79,"stargazers_count":12,"open_issues_count":6,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T04:06:03.270Z","etag":null,"topics":["distributed-computing","hydra","hydra-cli","hydra-express","microservice","microservices"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/pnxtech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-05T16:18:37.000Z","updated_at":"2023-07-07T14:37:51.000Z","dependencies_parsed_at":"2022-08-13T23:40:22.150Z","dependency_job_id":null,"html_url":"https://github.com/pnxtech/hydra-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnxtech%2Fhydra-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnxtech%2Fhydra-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnxtech%2Fhydra-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pnxtech%2Fhydra-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pnxtech","download_url":"https://codeload.github.com/pnxtech/hydra-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248339281,"owners_count":21087215,"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":["distributed-computing","hydra","hydra-cli","hydra-express","microservice","microservices"],"created_at":"2024-11-25T09:30:36.578Z","updated_at":"2025-04-11T04:06:08.633Z","avatar_url":"https://github.com/pnxtech.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# hydra-cli\n\n[![npm version](https://badge.fury.io/js/hydra-cli.svg)](https://badge.fury.io/js/hydra-cli) \u003cspan class=\"badge-npmdownloads\"\u003e\u003ca href=\"https://npmjs.org/package/hydra-cli\" title=\"View this project on NPM\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/hydra-cli.svg\" alt=\"NPM downloads\" /\u003e\u003c/a\u003e\u003c/span\u003e [![npm](https://img.shields.io/npm/l/hydra-cli.svg)]()\n\nHydra command line interface for use with [Hydra](https://github.com/flywheelsports/hydra) enabled microservices.\n\n## install\n\n```shell\n$ [sudo] npm install -g hydra-cli\n```\n\n## Command overview\n\n```\nhydra-cli version 1.8.0\nUsage: hydra-cli command [parameters]\nSee docs at: https://github.com/flywheelsports/hydra-cli\n\nA command line interface for Hydra services\n\nCommands:\n  help                         - this help list\n  cfg list serviceName         - display a list of config versions\n  cfg pull label               - download configuration file\n  cfg push label filename      - update configuration file\n  cfg remove label             - remove a configuration version\n  config instanceName          - configure connection to redis\n  config list                  - display current configuration\n  use instanceName             - name of redis instance to use\n  health [serviceName]         - display service health\n  healthlog serviceName        - display service health log\n  message create               - create a message object\n  message send message.json    - send a message\n  message queue message.json   - queue a message\n  nodes [serviceName]          - display service instance nodes\n  redis info                   - display redis info\n  refresh node list            - refresh list of nodes\n  rest path [payload.json]     - make an HTTP RESTful call to a service\n  routes [serviceName]         - display service API routes\n  services [serviceName]       - display list of services\n  shell                        - display command to open redis shell\n```\n\n## help\nLists the help screen above.\n\n\u003e syntax: hydra-cli help\n\n```shell\n$ hydra-cli help\n```\n\n## cfg\n\nHydra-cli allows you to push and pull configurations for your microservices.\n\nIn this example we're pushing the config.json file from the local directory and storing it in Redis under the myservice:0.0.1 key. This allows the `myservice` service to pull its 0.0.1 configuration during startup.\n\n```shell\n$ hydra-cli cfg push myservice:0.0.1 config.json\n```\n\nWe can download the configuration file for the myservice using:\n\n```shell\n$ hydra-cli cfg pull myservice:0.0.1 \u003e config.json\n```\n\nBecause the `cfg pull` command outputs the contents to screen you'll need to use the standard out redirection to copy the output to a file.\n\nYou can retrieve a list of config versions for a given service using:\n\n```shell\n$ hydra-cli cfg list myservice\n```\n\nTo remove an entry, use:\n\n```shell\n$ hydra-cli cfg remove myservice:0.0.1\n```\n\n## config\n\nHydra-cli requires that you first point it to the instance of Redis which your microservices are using.\nYou must name the instance you're configuring.\n\n\u003e syntax: hydra-cli config instanceName\n\n```shell\n$ hydra-cli config local\nredisUrl: 127.0.0.1\nredisPort: 6379\nredisDb: 15\n```\n\n## config list\nLists your config settings.\n\n\u003e syntax: hydra-cli config list\n\n```javascript\n$ hydra-cli config list\n{\n  \"version\": 2,\n  \"local\": {\n    \"redisUrl\": \"127.0.0.1\",\n    \"redisPort\": \"6379\",\n    \"redisDb\": \"15\"\n  }\n}\n```\n\n## use\nSpecify which redis instance to use.\n\n```javascript\n$ hydra-cli use local\n```\n\n## health\nThe health command displays the health of services which are currently running.\nIf you specify the name of a service than only that service is displayed.\n\n\u003e syntax: hydra-cli health [serviceName]\n\n\u003e serviceName is optional\n\n```javascript\n$ hydra-cli health\n[\n  [\n    {\n      \"updatedOn\": \"2016-11-22T18:01:49.637Z\",\n      \"serviceName\": \"hello-service\",\n      \"instanceID\": \"2c87057963121e1d7983bc952951ff3f\",\n      \"sampledOn\": \"2016-11-22T18:01:49.637Z\",\n      \"processID\": 54906,\n      \"architecture\": \"x64\",\n      \"platform\": \"darwin\",\n      \"nodeVersion\": \"v6.8.1\",\n      \"memory\": {\n        \"rss\": 41324544,\n        \"heapTotal\": 24154112,\n        \"heapUsed\": 20650296\n      },\n      \"uptime\": \"2 hours, 58 minutes, 27.68 seconds\",\n      \"uptimeSeconds\": 10707.68,\n      \"usedDiskSpace\": \"53%\"\n    }\n  ],\n  [\n    {\n      \"updatedOn\": \"2016-11-22T18:01:50.323Z\",\n      \"serviceName\": \"red-service\",\n      \"instanceID\": \"ce62591552a8b304d7236c820d0a4859\",\n      \"sampledOn\": \"2016-11-22T18:01:50.323Z\",\n      \"processID\": 13431,\n      \"architecture\": \"x64\",\n      \"platform\": \"darwin\",\n      \"nodeVersion\": \"v6.8.1\",\n      \"memory\": {\n        \"rss\": 45961216,\n        \"heapTotal\": 26251264,\n        \"heapUsed\": 20627944\n      },\n      \"uptime\": \"1 hour, 9 minutes, 19.038999999999536 seconds\",\n      \"uptimeSeconds\": 4159.039,\n      \"usedDiskSpace\": \"53%\"\n    }\n  ]\n]\n```\n\n## healthlog\nDisplays internal log for a service. The serviceName is required.\n\n\u003e syntax: hydra-cli healthlog serviceName\n\n\u003e serviceName is required\n\n```shell\n$ hydra-cli healthlog red-service\nfatal | 2016-11-22T16:51:58.609Z PID:12664: Port 6000 is already in use\n```\n\n## message create\nThe `message create` command will create a [UMF](https://github.com/cjus/umf) message which you can customize for use with the `message send` command.\n\n\u003e syntax: hydra-cli message create\n\n```shell\n$ hydra-cli message create\n{\n  \"to\": \"{serviceName here}:/\",\n  \"from\": \"hydra-cli:/\",\n  \"mid\": \"378572ab-3cd3-414b-b56f-3d2bbf089c19\",\n  \"timestamp\": \"2016-11-22T18:14:49.441Z\",\n  \"version\": \"UMF/1.4.3\",\n  \"body\": {}\n}\n```\n\nJust edit the to field with the name of the service you'd like to send a message to.\n\n## message send\n\n\u003e syntax: hydra-cli send message.json\n\n\u003e message.json is the name of a file containing JSON which you wish to send.  This field is required.\n\nThe `message send` command sends a [UMF](https://github.com/cjus/umf) fomatted message to a service. Use the `message create` command to create a message and place it in a file, such as message.json.\n\n```shell\n$ hydra-cli message send message.json\n```\n\n## message queue\n\n```shell\n$ hydra-cli message queue message.json\n```\n\nLike send message but the message is pushed on the a service's queue rather then sent directly to a service.\n\n## nodes\n\nDisplays a list of services instances (called nodes). If you specify a serviceName then only service instances with that name will be displayed.\n\n\u003e syntax: hydra-cli nodes [serviceName]\n\n\u003e serviceName is optional\n\n```javascript\n$ hydra-cli nodes\n[\n  {\n    \"serviceName\": \"red-service\",\n    \"serviceDescription\": \"red stuff\",\n    \"version\": \"0.0.1\",\n    \"instanceID\": \"6b8eacc1ead3e1f904647110ce8c092f\",\n    \"updatedOn\": \"2016-11-22T18:19:04.377Z\",\n    \"processID\": 3801,\n    \"ip\": \"10.1.1.163\",\n    \"port\": 6000,\n    \"elapsed\": 3\n  },\n  {\n    \"serviceName\": \"hello-service\",\n    \"serviceDescription\": \"Hello service demo\",\n    \"version\": \"not specified\",\n    \"instanceID\": \"2c87057963121e1d7983bc952951ff3f\",\n    \"updatedOn\": \"2016-11-22T18:19:02.943Z\",\n    \"processID\": 54906,\n    \"ip\": \"192.168.1.186\",\n    \"port\": 3000,\n    \"elapsed\": 4\n  }\n]\n```\n\n## redis\nYou can pull Redis runtime info using:\n\n```shell\n$ hydra-cli redis info\n# Server\nredis_version:3.0.7\nredis_git_sha1:00000000\nredis_git_dirty:0\nredis_build_id:9608eaf6bab769c5\nredis_mode:standalone\nos:Linux 4.9.49-moby x86_64\narch_bits:64\nmultiplexing_api:epoll\ngcc_version:4.9.2\n...\n```\n\n## refresh\nRefresh clears dead services from the nodes list.  Use this when `hydra-cli nodes` returns nodes which have expired.\n\n```javascript\n$ hydra-cli refresh node list\n```\n\n## rest\nThe `rest` command allows you to make a RESTful API call to a service which exposes HTTP endpoints.\n\n\u003e syntax: hydra-cli rest path [payload.json]\n\n\u003e payload is a file containing JSON which you wish to send with POST and PUT calls.\n\nNote the use of the path `hello-service:[get]/` below. This format is required.\nThe full format is: `{serviceID}@{serviceName}:{HTTP method get/post/put/delete etc...}{API path}\n\nThis is an example of how you would call an API endpoint on a specific service instance:\n\n```\n$ hydra-cli rest a921a00de7caf9103a0d96346b3a61f8@hello-service:[get]/v1/hello/greeting\n```\n\nYou may supply a file to upload when using `post` and `put` HTTP calls.\n\n\u003e You can locate a service's instance using the `hydra-cli nodes` command.\n\n```javascript\n$ hydra-cli rest hello-service:[get]/\n{\n  \"headers\": {\n    \"access-control-allow-origin\": \"*\",\n    \"x-process-id\": \"44032\",\n    \"x-dns-prefetch-control\": \"off\",\n    \"x-frame-options\": \"SAMEORIGIN\",\n    \"x-download-options\": \"noopen\",\n    \"x-content-type-options\": \"nosniff\",\n    \"x-xss-protection\": \"1; mode=block\",\n    \"x-powered-by\": \"hello-service/0.11.4\",\n    \"content-type\": \"text/html; charset=utf-8\",\n    \"content-length\": \"59\",\n    \"etag\": \"W/\\\"3b-Kwmf5A3/0YsqP+L3cGK3eg\\\"\",\n    \"x-response-time\": \"17.750ms\",\n    \"date\": \"Tue, 22 Nov 2016 19:09:51 GMT\",\n    \"connection\": \"close\"\n  },\n  \"body\": \"hello from hello-service - a921a00de7caf9103a0d96346b3a61f8\",\n  \"statusCode\": 200\n}\n```\n\nIf you forget to specify an HTTP type then you'll see a response like this one:\n\n```javascript\n$ hydra-cli rest hello-service:/\n{\n  \"statusCode\": 400,\n  \"statusMessage\": \"Bad Request\",\n  \"statusDescription\": \"Request is invalid, missing parameters?\",\n  \"result\": {\n    \"reason\": \"HTTP method not specified in `to` field\"\n  }\n}\n```\n\n## routes\nThe routes command will display routes which services register via hydra-express or via the use of the hydra.registerRoute call.\n\n\u003e syntax: hydra-cli routes\n\n```javascript\n$ hydra-cli routes\n{\n  \"hello-service\": [\n    \"[GET]/_config/hello-service\",\n    \"[get]/\"\n  ]\n}\n```\n\n## services\n\nDisplay a list of registered services.\n\n\u003e syntax: hydra-cli services\n\n```javascript\n$ hydra-cli services\n[\n  {\n    \"serviceName\": \"hello-service\",\n    \"type\": \"demo\",\n    \"registeredOn\": \"2016-11-22T19:09:47.772Z\"\n  },\n  {\n    \"serviceName\": \"red-service\",\n    \"type\": \"red\",\n    \"registeredOn\": \"2016-11-22T19:31:31.061Z\"\n  },\n  {\n    \"serviceName\": \"blue-service\",\n    \"type\": \"blue\",\n    \"registeredOn\": \"2016-11-22T19:31:27.853Z\"\n  }\n]\n```\n\n## shell\n\nDisplay command used to open a redis shell using redis-cli. On *nix machines you can use the following to quickly open a redis shell:\n\n```shell\n$ $(hydra-cli shell)\n52.3.229.252:6379[15]\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnxtech%2Fhydra-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpnxtech%2Fhydra-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpnxtech%2Fhydra-cli/lists"}