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

Session

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

Consul /session endpoing

Subcommand Synopsis
create Create a new session
destroy Destroy a session
info Get information on a session
list List active sessions for a datacenter
node Get active sessions for a node
renew Renew the given session

create

API Reference

Create new session

Basic Usage

Usage: consul-cli session list [options]

Command Line Options

  • --lock-delay=<duration>
    The amount of time before another process can acquire the lock after it is released. A duration of zero indicates that the lock can be immediately acquired after release. The default is 15s

  • --name=<sessionName>
    Assign the human-readable name to the session

  • --node=<nodeName>
    Associate the newly created session with nodeName. By default, the agent's name is used

  • --checks=<checkName>
    Associate the check with the newly created session. Multiple --checks options can be specified on the command line

  • --behavior=[delete|release]
    Lock behavior when the session is invalidated

  • --ttl=<duration>
    Time to Live for the session. A value of zero indicates that the session does not expire. The default is 15s

Examples

$ ./consul-cli session create --ttl=0
d385ba9d-696e-4b98-5962-18bad549247e

destroy

API Reference

Destroy the given session

Basic Usage

Usage: consul-cli session destroy [options] sessionId

Examples

$ ./consul-cli session destroy d385ba9d-696e-4b98-5962-18bad549247e
$

info

API Reference

Get information on a session

Basic Usage

Usage: consul-cli session info [options] sessionId

Examples

$ ./consul-cli session info d385ba9d-696e-4b98-5962-18bad549247e
{
  "CreateIndex": 462,
  "ID": "d385ba9d-696e-4b98-5962-18bad549247e",
  "Name": "",
  "Node": "default",
  "Checks": [
    "serfHealth"
  ],
  "LockDelay": 0,
  "Behavior": "release",
  "TTL": "0"
}

list

API Reference

List active sessions for a datacenter

Basic Usage

Usage: consul-cli session list [options]

Examples

$ ./consul-cli session list 
[
  {
    "CreateIndex": 462,
    "ID": "d385ba9d-696e-4b98-5962-18bad549247e",
    "Name": "",
    "Node": "default",
    "Checks": [
      "serfHealth"
    ],
    "LockDelay": 0,
    "Behavior": "release",
    "TTL": "0"
  }
]

node

API Reference

Get the active sessions for a node

Basic Usage

Usage: consul-cli session node [options] nodeName

Examples

$ ./consul-cli session node default
[
  {
    "CreateIndex": 462,
    "ID": "d385ba9d-696e-4b98-5962-18bad549247e",
    "Name": "",
    "Node": "default",
    "Checks": [
      "serfHealth"
    ],
    "LockDelay": 0,
    "Behavior": "release",
    "TTL": "0"
  }
]

renew

API Reference

Renew the given TTL session

Basic Usage

Usage: consul-cli session renew [options] sessionId

Examples

$ ./consul-cli session renew d385ba9d-696e-4b98-5962-18bad549247e
{
  "CreateIndex": 462,
  "ID": "d385ba9d-696e-4b98-5962-18bad549247e",
  "Name": "",
  "Node": "default",
  "Checks": [
    "serfHealth"
  ],
  "LockDelay": 0,
  "Behavior": "release",
  "TTL": "0"
}