-
Notifications
You must be signed in to change notification settings - Fork 67
Service
Subcommand | Synopsis |
---|---|
deregister | Remove a service from the agent |
maintenance | Manage maintenance mode of a service |
register | Register a new local service |
Remove a service from the agent
Usage: consul-cli service deregister [options] serviceId
$ ./consul-cli service deregister test:test_service
$
Manage maintenance mode for a service
Usage: consul-cli service maintenance [options] serviceId
-
--enabled
Whentrue
, enable maintenance mode on the service. The default istrue
-
--reason
Optional text explaining the reason for putting the service in maintenance mode
$ ./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 a new service with the agent
Usage: consul-cli service register [options] serviceName
-
--id
The id for the service. If this is not provided theserviceName
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
$ ./consul-cli service register --id=test:test_service --tag=worker --tag=drone \
--check="ttl:30s" --check="http:30s:http://localhost:5000/health" \
test_service