• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.circleci/H02-Oct-2019-11093

client/H02-Oct-2019-1,056815

cmd/serf/H02-Oct-2019-10,5278,103

coordinate/H02-Oct-2019-1,431975

demo/H02-Oct-2019-686512

ops-misc/H02-Oct-2019-414271

scripts/H02-Oct-2019-243156

serf/H02-Oct-2019-9,9357,184

testutil/H02-Oct-2019-288212

vendor/H03-May-2022-276,952226,750

website/H03-May-2022-5,7794,588

.gitignoreH A D02-Oct-2019361 3527

CHANGELOG.mdH A D02-Oct-201915 KiB443288

GNUmakefileH A D02-Oct-20191.7 KiB6642

LICENSEH A D02-Oct-201915.6 KiB355256

README.mdH A D02-Oct-20194.8 KiB12293

go.modH A D02-Oct-2019693 1816

go.sumH A D02-Oct-20197 KiB7675

README.md

1# Serf [![Build Status](https://travis-ci.org/hashicorp/serf.png)](https://travis-ci.org/hashicorp/serf) [![Join the chat at https://gitter.im/hashicorp-serf/Lobby](https://badges.gitter.im/hashicorp-serf/Lobby.svg)](https://gitter.im/hashicorp-serf/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
2
3* Website: https://www.serf.io
4* Chat: [Gitter](https://gitter.im/hashicorp-serf/Lobby)
5* Mailing list: [Google Groups](https://groups.google.com/group/serfdom/)
6
7Serf is a decentralized solution for service discovery and orchestration
8that is lightweight, highly available, and fault tolerant.
9
10Serf runs on Linux, Mac OS X, and Windows. An efficient and lightweight gossip
11protocol is used to communicate with other nodes. Serf can detect node failures
12and notify the rest of the cluster. An event system is built on top of
13Serf, letting you use Serf's gossip protocol to propagate events such
14as deploys, configuration changes, etc. Serf is completely masterless
15with no single point of failure.
16
17Here are some example use cases of Serf, though there are many others:
18
19* Discovering web servers and automatically adding them to a load balancer
20* Organizing many memcached or redis nodes into a cluster, perhaps with
21  something like [twemproxy](https://github.com/twitter/twemproxy) or
22  maybe just configuring an application with the address of all the
23  nodes
24* Triggering web deploys using the event system built on top of Serf
25* Propagating changes to configuration to relevant nodes.
26* Updating DNS records to reflect cluster changes as they occur.
27* Much, much more.
28
29## Quick Start
30
31First, [download a pre-built Serf binary](https://www.serf.io/downloads.html)
32for your operating system, [compile Serf yourself](#developing-serf), or install
33using `go get -u github.com/hashicorp/serf/cmd/serf`.
34
35Next, let's start a couple Serf agents. Agents run until they're told to quit
36and handle the communication of maintenance tasks of Serf. In a real Serf
37setup, each node in your system will run one or more Serf agents (it can
38run multiple agents if you're running multiple cluster types. e.g. web
39servers vs. memcached servers).
40
41Start each Serf agent in a separate terminal session so that we can see
42the output of each. Start the first agent:
43
44```
45$ serf agent -node=foo -bind=127.0.0.1:5000 -rpc-addr=127.0.0.1:7373
46...
47```
48
49Start the second agent in another terminal session (while the first is still
50running):
51
52```
53$ serf agent -node=bar -bind=127.0.0.1:5001 -rpc-addr=127.0.0.1:7374
54...
55```
56
57At this point two Serf agents are running independently but are still
58unaware of each other. Let's now tell the first agent to join an existing
59cluster (the second agent). When starting a Serf agent, you must join an
60existing cluster by specifying at least one existing member. After this,
61Serf gossips and the remainder of the cluster becomes aware of the join.
62Run the following commands in a third terminal session.
63
64```
65$ serf join 127.0.0.1:5001
66...
67```
68
69If you're watching your terminals, you should see both Serf agents
70become aware of the join. You can prove it by running `serf members`
71to see the members of the Serf cluster:
72
73```
74$ serf members
75foo    127.0.0.1:5000    alive
76bar    127.0.0.1:5001    alive
77...
78```
79
80At this point, you can ctrl-C or force kill either Serf agent, and they'll
81update their membership lists appropriately. If you ctrl-C a Serf agent,
82it will gracefully leave by notifying the cluster of its intent to leave.
83If you force kill an agent, it will eventually (usually within seconds)
84be detected by another member of the cluster which will notify the
85cluster of the node failure.
86
87## Documentation
88
89Full, comprehensive documentation is viewable on the Serf website:
90
91https://www.serf.io/docs
92
93## Developing Serf
94
95If you wish to work on Serf itself, you'll first need [Go](https://golang.org)
96installed (version 1.10+ is _required_). Make sure you have Go properly
97[installed](https://golang.org/doc/install),
98including setting up your [GOPATH](https://golang.org/doc/code.html#GOPATH).
99
100Next, clone this repository into `$GOPATH/src/github.com/hashicorp/serf` and
101then just type `make`. In a few moments, you'll have a working `serf` executable:
102
103```
104$ make
105...
106$ bin/serf
107...
108```
109
110*NOTE: `make` will also place a copy of the executable under `$GOPATH/bin/`*
111
112Serf is first and foremost a library with a command-line interface, `serf`. The
113Serf library is independent of the command line agent, `serf`.  The `serf`
114binary is located under `cmd/serf` and can be installed stand alone by issuing
115the command `go get -u github.com/hashicorp/serf/cmd/serf`.  Applications using
116the Serf library should only need to include `github.com/hashicorp/serf`.
117
118Tests can be run by typing `make test`.
119
120If you make any changes to the code, run `make format` in order to automatically
121format the code according to Go [standards](https://golang.org/doc/effective_go.html#formatting).
122