website: replacing serf references

This commit is contained in:
Armon Dadgar 2014-02-18 17:33:44 -08:00
parent c200b63204
commit ed2622d0c8
2 changed files with 6 additions and 90 deletions

View File

@ -1,84 +0,0 @@
---
layout: "docs"
page_title: "Event Handlers"
sidebar_current: "docs-agent-events"
---
# Event Handlers
Serf's true power and flexibility comes in the form of event handlers:
scripts that are executed in response to various events that can occur
related to the Serf cluster. Serf invokes events related to membership
changes (when a node comes online or goes offline) as well as
[custom events](/docs/commands/event.html).
Event handlers can be any executable, including piped executables (such
as `awk '{print $2}' | grep foo`, since event handlers are invoked within
the context of a shell. The event handler is executed anytime an event
occurs and are expected to exit within a reasonable amount of time.
## Inputs and Parameters
Every time an event handler is invoked, Serf sets some environmental
variables:
* `SERF_EVENT` is the event type that is occuring. This will be one of
`member-join`, `member-leave`, `member-failed`, or `user`.
* `SERF_SELF_NAME` is the name of the node that is executing the event handler.
* `SERF_SELF_ROLE` is the role of the node that is executing the event handler.
* `SERF_TAG_${TAG}` is set for each tag the agent has. The tag name is upper-cased.
* `SERF_USER_EVENT` is the name of the user event type if `SERF_EVENT` is
"user".
* `SERF_USER_LTIME` is the `LamportTime` of the user event if `SERF_EVENT`
is "user".
In addition to these environmental variables, the data for an event is passed
in via stdin. The format of the data is dependent on the event type.
#### Membership Event Data
For membership related events (`member-join`, `member-leave`, `member-failed`, and `member-update`),
stdin is the list of members that participated in that event. Each member is
separated by a newline and each field about the member is separated by
whitespace. The fields of a membership event are name, address, role, then tags.
For example:
```
mitchellh.local 127.0.0.1 web role=web,datacenter=east
```
#### User Event Data
For user events, stdin is the payload (if any) of the user event.
## Specifying Event Handlers
Event handlers are specified using the `-event-handler` flag for
`serf agent`. This flag can be specified multiple times for multiple
event handlers, in which case each event handler will be executed.
Event handlers can also be filtered by event type. By default, the event
handler will be invoked for any event which may occur. But you can restrict
the events the event handler is invoked for by using a simple syntax
of `type=script`. Below are all the available ways this syntax can be
used to filter an event handler:
* `foo.sh` - The script "foo.sh" will be invoked for any/every event.
* `member-join=foo.sh` - The script "foo.sh" will only be invoked for the
"member-join" event.
* `member-join,member-leave=foo.sh` - The script "foo.sh" will be invoked
for either member-join or member-leave events. Any combination of events
may be specified in this way.
* `user=foo.sh` - The script "foo.sh" will be invoked for all user events.
* `user:deploy=foo.sh` - The script "foo.sh" will be invoked only for
"deploy" user events.

View File

@ -52,20 +52,20 @@ The options below are all specified on the command-line.
will merge with configuration files loaded earlier, with the later values
overriding the earlier values.
* `-config-dir` - A directory of configuration files to load. Serf will
* `-config-dir` - A directory of configuration files to load. Consul will
load all files in this directory ending in ".json" as configuration files
in alphabetical order. For more information on the format of the configuration
files, see the "Configuration Files" section below.
* `-encrypt` - Specifies the secret key to use for encryption of Serf
* `-encrypt` - Specifies the secret key to use for encryption of Consul
network traffic. This key must be 16-bytes that are base64 encoded. The
easiest way to create an encryption key is to use `consul keygen`. All
nodes within a cluster must share the same encryption key to communicate.
* `-log-level` - The level of logging to show after the Serf agent has
* `-log-level` - The level of logging to show after the Consul agent has
started. This defaults to "info". The available log levels are "trace",
"debug", "info", "warn", "err". This is the log level that will be shown
for the agent output, but note you can always connect via `serf monitor`
for the agent output, but note you can always connect via `consul monitor`
to an agent at any log level. The log level can be changed during a
config reload.
@ -74,7 +74,7 @@ The options below are all specified on the command-line.
* `-rpc-addr` - The address that Consul will bind to for the agent's RPC server.
By default this is "127.0.0.1:8400", allowing only loopback connections.
The RPC address is used by other Serf commands, such as `consul members`,
The RPC address is used by other Consul commands, such as `consul members`,
in order to query a running Consul agent. It is also used by other applications
to control Consul using it's [RPC protocol](/docs/agent/rpc.html).
@ -117,7 +117,7 @@ The options below are all specified on the command-line.
## Configuration Files
In addition to the command-line options, configuration can be put into
files. This may be easier in certain situations, for example when Serf is
files. This may be easier in certain situations, for example when Consul is
being configured using a configuration management system.
The configuration files are JSON formatted, making them easily readable