|
|
|
@ -11,6 +11,7 @@ import (
|
|
|
|
|
"net"
|
|
|
|
|
"os"
|
|
|
|
|
"os/signal"
|
|
|
|
|
"regexp"
|
|
|
|
|
"runtime"
|
|
|
|
|
"strings"
|
|
|
|
|
"syscall"
|
|
|
|
@ -20,6 +21,9 @@ import (
|
|
|
|
|
// gracefulTimeout controls how long we wait before forcefully terminating
|
|
|
|
|
var gracefulTimeout = 5 * time.Second
|
|
|
|
|
|
|
|
|
|
// validDatacenter is used to validate a datacenter
|
|
|
|
|
var validDatacenter = regexp.MustCompile("^[a-zA-Z0-9_-]+$")
|
|
|
|
|
|
|
|
|
|
// Command is a Command implementation that runs a Consul agent.
|
|
|
|
|
// The command will not end unless a shutdown message is sent on the
|
|
|
|
|
// ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly
|
|
|
|
@ -111,6 +115,12 @@ func (c *Command) readConfig() *Config {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Verify data center is valid
|
|
|
|
|
if !validDatacenter.MatchString(config.Datacenter) {
|
|
|
|
|
c.Ui.Error("Datacenter must be alpha-numeric with underscores and hypens only")
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Only allow bootstrap mode when acting as a server
|
|
|
|
|
if config.Bootstrap && !config.Server {
|
|
|
|
|
c.Ui.Error("Bootstrap mode cannot be enabled when server mode is not enabled")
|
|
|
|
|