A simple program to show how to integrate serf.
go-hello-serfIn 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-demoVerify 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-demoIn 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-demoIn 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-demoIn terminal #5
serf agent -join 172.17.0.2In 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 | jqexport 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.gitcd ${REPOSITORY_DIR}
make dependenciescd ${REPOSITORY_DIR}
makeThe results will be in the ${GOPATH}/bin directory.
Create rpm and deb installation packages.
cd ${REPOSITORY_DIR}
make buildThe results will be in the ${REPOSITORY_DIR}/target directory.
cd ${REPOSITORY_DIR}
make test-localExample distributions: openSUSE, Fedora, CentOS, Mandrake
Example:
sudo rpm -ivh go-hello-serf-M.m.P-I.x86_64.rpmExample:
sudo rpm -Uvh go-hello-serf-M.m.P-I.x86_64.rpmExample distributions: Ubuntu
Example:
sudo dpkg -i go-hello-serf_M.m.P-I_amd64.debcd ${REPOSITORY_DIR}
make clean