etcdserver: rename db file into a formal directory

and rename it to a formal name
release-2.3
Yicheng Qin 2015-09-14 22:15:23 -07:00
parent 51f1ee055e
commit 05c74bd890
2 changed files with 10 additions and 3 deletions

View File

@ -119,6 +119,8 @@ func (c *ServerConfig) WALDir() string {
func (c *ServerConfig) SnapDir() string { return path.Join(c.MemberDir(), "snap") }
func (c *ServerConfig) StorageDir() string { return path.Join(c.MemberDir(), "storage") }
func (c *ServerConfig) ShouldDiscover() bool { return c.DiscoveryURL != "" }
// ReqTimeout returns timeout for request to finish.

View File

@ -62,6 +62,8 @@ const (
purgeFileInterval = 30 * time.Second
monitorVersionInterval = 5 * time.Second
databaseFilename = "db"
)
var (
@ -181,8 +183,7 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
var id types.ID
var cl *cluster
demoFile := path.Join(cfg.MemberDir(), "v3demo")
if !cfg.V3demo && fileutil.Exist(demoFile) {
if !cfg.V3demo && fileutil.Exist(path.Join(cfg.StorageDir(), databaseFilename)) {
return nil, errors.New("experimental-v3demo cannot be disabled once it is enabled")
}
@ -330,7 +331,11 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
}
if cfg.V3demo {
srv.kv = dstorage.New(demoFile)
err = os.MkdirAll(cfg.StorageDir(), privateDirMode)
if err != nil && err != os.ErrExist {
return nil, err
}
srv.kv = dstorage.New(path.Join(cfg.StorageDir(), databaseFilename))
}
// TODO: move transport initialization near the definition of remote