A simple program to show how to integrate serf.
go-hello-serf
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
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"
mkdir -p ${PROJECT_DIR}
cd ${PROJECT_DIR}
git clone [email protected]:docktermj/go-hello-serf.git
cd ${REPOSITORY_DIR}
make dependencies
cd ${REPOSITORY_DIR}
make
The results will be in the ${GOPATH}/bin
directory.
Create rpm
and deb
installation packages.
cd ${REPOSITORY_DIR}
make build
The results will be in the ${REPOSITORY_DIR}/target
directory.
cd ${REPOSITORY_DIR}
make test-local
Example distributions: openSUSE, Fedora, CentOS, Mandrake
Example:
sudo rpm -ivh go-hello-serf-M.m.P-I.x86_64.rpm
Example:
sudo rpm -Uvh go-hello-serf-M.m.P-I.x86_64.rpm
Example distributions: Ubuntu
Example:
sudo dpkg -i go-hello-serf_M.m.P-I_amd64.deb
cd ${REPOSITORY_DIR}
make clean