Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Service

Chris Aubuchon edited this page Feb 5, 2016 · 4 revisions

Consul /agent/service endpoint

Subcommand Synopsis
deregister Remove a service from the agent
maintenance Manage maintenance mode of a service
register Register a new local service

deregister

API Reference

Remove a service from the agent

Basic Usage

Usage: consul-cli service deregister [options] serviceId

Examples

$ ./consul-cli service deregister test:test_service
$

maintenance

API Reference

Manage maintenance mode for a service

Basic Usage

Usage: consul-cli service maintenance [options] serviceId

Command Line Options

  • --enabled
    When true, enable maintenance mode on the service. The default is true

  • --reason
    Optional text explaining the reason for putting the service in maintenance mode

Examples

$ ./consul-cli service maintenance test:test_service
$ ./consul-cli health service test_service
[
  {
  ...
      "Checks": [
      {
        "Node": "default",
        "CheckID": "_service_maintenance:test:test_service",
        "Name": "Service Maintenance Mode",
        "Status": "critical",
        "Notes": "Maintenance mode is enabled for this service, but no reason was provided. This is a default message.",
        "Output": "",
        "ServiceID": "test:test_service",
        "ServiceName": "test_service"
      },
    ]
  }
]
$ ./consul-cli service maintenance --enabled=false test:test_service
$

register

API Reference

Register a new service with the agent

Basic Usage

Usage: consul-cli service register [options] serviceName

Command Line Options

  • --id
    The id for the service. If this is not provided the serviceName is used. Duplicates IDs cannot exist on an agent so specifying an id may be required

  • --tag=<tagName>
    Tags to associate with the service. Multiple --tag options can be specified on the command line

  • --address=<address>
    Net address for the service

  • --port=<portNumber>
    Network port for the service

  • --check="[http|script|ttl]:<interval>:[<url>|<command>]" Create a check for for the service. Multiple --check` options can be specified on the command line

Examples

$ ./consul-cli service register --id=test:test_service --tag=worker --tag=drone \
    --check="ttl:30s" --check="http:30s:http://localhost:5000/health" \
    test_service
Clone this wiki locally