fix readme and remove swarm prefix

Signed-off-by: JChien <jeffchien13@gmail.com>
This commit is contained in:
JChien 2014-12-17 15:28:42 +08:00 committed by Victor Vieux
parent 1a21de143f
commit e0461c7549
3 changed files with 5 additions and 11 deletions

View File

@ -81,17 +81,13 @@ http://<node_ip:2375>
###### Using consul
```bash
# create a cluster
$ swarm create
6856663cdefdec325839a4b7e1de38e8
# on each of your nodes, start the swarm agent
# <node_ip> doesn't have to be public (eg. 192.168.0.X),
# as long as the other nodes can reach it, it is fine.
$ swarm join --discovery consul://<consul_addr>/>6856663cdefdec325839a4b7e1de38e8> --addr=<node_ip:2375>
$ swarm join --discovery consul://<consul_addr>/<path> --addr=<node_ip:2375>
# start the manager on any machine or your laptop
$ swarm manage --discovery consul://<consul_addr>/>6856663cdefdec325839a4b7e1de38e8> --addr=<swarm_ip:swarm_port>
$ swarm manage --discovery consul://<consul_addr>/<path> --addr=<swarm_ip:swarm_port>
# use the regular docker cli
$ docker -H <swarm_ip:swarm_port> info
@ -101,7 +97,7 @@ $ docker -H <swarm_ip:swarm_port> logs ...
...
# list nodes in your cluster
$ swarm list --discovery consul://<consul_addr>/>path>
$ swarm list --discovery consul://<consul_addr>/<path>
http://<node_ip:2375>
```

View File

@ -16,8 +16,6 @@ type ConsulDiscoveryService struct {
prefix string
}
const swarm_prefix = "swarm"
func init() {
discovery.Register("consul", &ConsulDiscoveryService{})
}
@ -39,7 +37,7 @@ func (s *ConsulDiscoveryService) Initialize(uris string, heartbeat int) error {
}
s.client = client
s.heartbeat = uint64(heartbeat)
s.prefix = swarm_prefix + "/" + path + "/"
s.prefix = path + "/"
kv := s.client.KV()
p := &consul.KVPair{Key: s.prefix, Value: nil}
_, err = kv.Put(p, nil)

View File

@ -9,5 +9,5 @@ import (
func TestInitialize(t *testing.T) {
discovery := &ConsulDiscoveryService{}
discovery.Initialize("127.0.0.1:8500/path", 0)
assert.Equal(t, discovery.prefix, "swarm/path/")
assert.Equal(t, discovery.prefix, "path/")
}