feat(etcd): create unique directory on no-flag case

Tell etcd to store the log and configuration into directory in the
pattern of `${machineName}.etcd` if no directory is specified.
This commit is contained in:
Brandon Philips 2013-11-13 10:16:02 -08:00
parent 5abbaf59e3
commit eecd9f7e35
2 changed files with 11 additions and 6 deletions

16
etcd.go
View File

@ -47,11 +47,6 @@ func main() {
log.Verbose = true
}
// Create data directory if it doesn't already exist.
if err := os.MkdirAll(config.DataDir, 0744); err != nil {
log.Fatalf("Unable to create path: %s", err)
}
// Load info object.
info, err := config.Info()
if err != nil {
@ -66,6 +61,17 @@ func main() {
info.Name = host
}
// Setup a default directory based on the machine name
if config.DataDir == "" {
config.DataDir = info.Name + ".etcd"
log.Warnf("Using the directory %s as the etcd configuration directory because a directory was not specified. ", config.DataDir)
}
// Create data directory if it doesn't already exist.
if err := os.MkdirAll(config.DataDir, 0744); err != nil {
log.Fatalf("Unable to create path: %s", err)
}
// Retrieve TLS configuration.
tlsConfig, err := info.EtcdTLS.Config()
if err != nil {

View File

@ -57,7 +57,6 @@ func NewConfig() *Config {
c.SystemPath = DefaultSystemConfigPath
c.AdvertisedUrl = "127.0.0.1:4001"
c.AdvertisedUrl = "127.0.0.1:4001"
c.DataDir = "."
c.MaxClusterSize = 9
c.MaxResultBuffer = 1024
c.MaxRetryAttempts = 3