diff --git a/etcd.go b/etcd.go index 340bcf9e..c0da55a6 100644 --- a/etcd.go +++ b/etcd.go @@ -1539,6 +1539,8 @@ func (obj *EmbdEtcd) StartServer(newCluster bool, peerURLsMap etcdtypes.URLsMap) err = os.MkdirAll(obj.dataDir, 0770) if err != nil { + log.Printf("Etcd: StartServer: Couldn't mkdir: %s.", obj.dataDir) + log.Printf("Etcd: StartServer: Mkdir error: %s.", err) obj.DestroyServer() return err } diff --git a/main.go b/main.go index ff72bee0..95f5826b 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ import ( etcdtypes "github.com/coreos/etcd/pkg/types" "github.com/coreos/pkg/capnslog" "github.com/urfave/cli" + "io/ioutil" "log" "os" "os/signal" @@ -121,6 +122,22 @@ func run(c *cli.Context) error { return cli.NewExitError("", 1) } + // make sure the working directory prefix exists + if err := os.MkdirAll(prefix, 0770); err != nil { + if c.Bool("allow-tmp-prefix") { + if prefix, err = ioutil.TempDir("", program); err != nil { + log.Printf("Main: Error: Can't create temporary prefix!") + return cli.NewExitError("", 1) + } + log.Println("Main: Warning: Working prefix directory is temporary!") + + } else { + log.Printf("Main: Error: Can't create prefix!") + return cli.NewExitError("", 1) + } + } + log.Printf("Main: Working prefix is: %s", prefix) + var wg sync.WaitGroup exit := make(chan bool) // exit signal var G, fullGraph *Graph @@ -472,6 +489,10 @@ func main() { Name: "no-caching", Usage: "don't allow remote caching of remote execution binary", }, + cli.BoolFlag{ + Name: "allow-tmp-prefix", + Usage: "allow creation of a new temporary prefix if main prefix is unavailable", + }, }, }, }