go-hello-serf

command module
v0.0.0-...-ca83aa4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2018 License: MIT Imports: 14 Imported by: 0

README

go-hello-serf

Usage

A simple program to show how to integrate serf.

Invocation
go-hello-serf

Demonstrate

In terminal #1

export GOPATH="${HOME}/go"
export PATH="${PATH}:${GOPATH}/bin:/usr/local/go/bin"
export PROJECT_DIR="${GOPATH}/src/github.com/docktermj"
export REPOSITORY_DIR="${PROJECT_DIR}/go-hello-serf"

cd ${REPOSITORY_DIR}
make dependencies

cd ${REPOSITORY_DIR}
make build-demo

Verify docker network is 172.17.0.1. If gateway is not 172.17.0.1, the following docker statements need to be modified before being run.

$ docker network inspect bridge | grep Gateway
                   "Gateway": "172.17.0.1"

In terminal #2

docker run -e ADVERTISE_ADDR=172.17.0.2 -p 8080:8080 local/go-hello-serf-demo

In terminal #3

docker run -e ADVERTISE_ADDR=172.17.0.3 -e CLUSTER_ADDR=172.17.0.2 -p 8081:8080 local/go-hello-serf-demo

In terminal #4

docker run -e ADVERTISE_ADDR=172.17.0.4 -e CLUSTER_ADDR=172.17.0.3 -p 8082:8080 local/go-hello-serf-demo

In terminal #5

serf agent -join 172.17.0.2

In terminal #6, try these commands

serf members
serf query time
serf event bob

curl -v http://localhost:8080/get | jq
curl -v http://localhost:8082/set/7
curl -v http://localhost:8080/get | jq

Development

Dependencies
Set environment variables
export GOPATH="${HOME}/go"
export PATH="${PATH}:${GOPATH}/bin:/usr/local/go/bin"
export PROJECT_DIR="${GOPATH}/src/github.com/docktermj"
export REPOSITORY_DIR="${PROJECT_DIR}/go-hello-serf"
Download project
mkdir -p ${PROJECT_DIR}
cd ${PROJECT_DIR}
git clone git@github.com:docktermj/go-hello-serf.git
Download dependencies
cd ${REPOSITORY_DIR}
make dependencies
Build
Local build
cd ${REPOSITORY_DIR}
make

The results will be in the ${GOPATH}/bin directory.

Docker build

Create rpm and deb installation packages.

cd ${REPOSITORY_DIR}
make build

The results will be in the ${REPOSITORY_DIR}/target directory.

Test
cd ${REPOSITORY_DIR}
make test-local
Install
RPM-based

Example distributions: openSUSE, Fedora, CentOS, Mandrake

RPM Install

Example:

sudo rpm -ivh go-hello-serf-M.m.P-I.x86_64.rpm
RPM Update

Example:

sudo rpm -Uvh go-hello-serf-M.m.P-I.x86_64.rpm
Debian

Example distributions: Ubuntu

Debian Install / Update

Example:

sudo dpkg -i go-hello-serf_M.m.P-I_amd64.deb
Cleanup
cd ${REPOSITORY_DIR}
make clean
References
  1. Building a simple, distributed one-value database with Hashicorp Serf

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL