Don't require the user to specify localhost when manually listing hosts

This commit is contained in:
Tom Wilkie
2016-05-12 11:12:58 +01:00
parent 8dbd8e1344
commit f346ec535c
5 changed files with 44 additions and 8 deletions

View File

@@ -0,0 +1,13 @@
#! /bin/bash
. ./config.sh
start_suite "Launch scope and check it boots, with a spurious host arg"
scope_on $HOST1 launch noatrealhost.foo
wait_for_containers $HOST1 60 weavescope
has_container $HOST1 weavescope
scope_end_suite

View File

@@ -4,8 +4,8 @@
start_suite "Launch 2 scopes and check they cluster (without weave)"
scope_on $HOST1 launch $HOST1 $HOST2
scope_on $HOST2 launch $HOST1 $HOST2
scope_on $HOST1 launch $HOST2
scope_on $HOST2 launch $HOST1
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
docker_on $HOST2 run -dit --name db2 peterbourgon/tns-db

View File

@@ -0,0 +1,17 @@
#! /bin/bash
. ./config.sh
start_suite "Launch 2 scopes and check they cluster (without weave)"
scope_on $HOST1 launch --no-app $HOST2
scope_on $HOST2 launch --no-probe
docker_on $HOST1 run -dit --name db1 peterbourgon/tns-db
sleep 30 # need to allow the scopes to poll dns, resolve the other app ids, and send them reports.
has_container $HOST2 weavescope
has_container $HOST2 db1
scope_end_suite

View File

@@ -68,6 +68,7 @@ type probeFlags struct {
logPrefix string
logLevel string
resolver string
noApp bool
dockerEnabled bool
dockerInterval time.Duration
@@ -115,12 +116,13 @@ func main() {
flag.BoolVar(&debug, "debug", false, "Force debug logging.")
flag.StringVar(&weaveHostname, "weave.hostname", "", "Hostname to advertise/lookup in WeaveDNS")
// We can ignore these - we need to know how to parse them, but they are interpreted by the entrypoint script.
// They are also here so they are included in usage.
flag.Bool("no-app", false, "Don't run the app.")
// We need to know how to parse them, but they are mainly interpreted by the entrypoint script.
// They are also here so they are included in usage, and the probe uses them to decide if to
// publish to localhost.
noApp := flag.Bool("no-app", false, "Don't run the app.")
probeOnly := flag.Bool("app-only", false, "Only run the app")
flag.Bool("probe-only", false, "Only run the probe.")
flag.Bool("no-probe", false, "Don't run the probe.")
flag.Bool("app-only", false, "Only run the app")
// Probe flags
flag.StringVar(&flags.probe.token, "service-token", "", "Token to use to authenticate with scope.weave.works")
@@ -176,6 +178,7 @@ func main() {
flags.probe.weaveHostname = weaveHostname
flags.app.weaveHostname = weaveHostname
}
flags.probe.noApp = *noApp || *probeOnly
switch mode {
case "app":

View File

@@ -94,9 +94,12 @@ func probeMain(flags probeFlags) {
}
go check(checkpointFlags)
var targets = []string{fmt.Sprintf("localhost:%d", xfer.AppPort)}
var targets = []string{}
if !flags.noApp {
targets = append(targets, fmt.Sprintf("localhost:%d", xfer.AppPort))
}
if len(flag.Args()) > 0 {
targets = flag.Args()
targets = append(targets, flag.Args()...)
}
log.Infof("publishing to: %s", strings.Join(targets, ", "))