add command line varible -i to ignore the existing configuration
This commit is contained in:
14
etcd.go
14
etcd.go
@ -46,6 +46,7 @@ var clientCAFile string
|
|||||||
|
|
||||||
var dirPath string
|
var dirPath string
|
||||||
|
|
||||||
|
var ignore bool
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.BoolVar(&verbose, "v", false, "verbose logging")
|
flag.BoolVar(&verbose, "v", false, "verbose logging")
|
||||||
@ -66,6 +67,8 @@ func init() {
|
|||||||
flag.StringVar(&clientKeyFile, "clientKey", "", "the key file of the client")
|
flag.StringVar(&clientKeyFile, "clientKey", "", "the key file of the client")
|
||||||
|
|
||||||
flag.StringVar(&dirPath, "d", "./", "the directory to store log and snapshot")
|
flag.StringVar(&dirPath, "d", "./", "the directory to store log and snapshot")
|
||||||
|
|
||||||
|
flag.BoolVar(&ignore, "i", false , "ignore the old configuration, create a new node")
|
||||||
}
|
}
|
||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
@ -392,6 +395,17 @@ func getInfo(path string) *Info {
|
|||||||
|
|
||||||
// Read in the server info if available.
|
// Read in the server info if available.
|
||||||
infoPath := fmt.Sprintf("%s/info", path)
|
infoPath := fmt.Sprintf("%s/info", path)
|
||||||
|
|
||||||
|
// delete the old configuration if exist
|
||||||
|
if ignore {
|
||||||
|
logPath := fmt.Sprintf("%s/log", path)
|
||||||
|
snapshotPath := fmt.Sprintf("%s/snapshotPath", path)
|
||||||
|
os.Remove(infoPath)
|
||||||
|
os.Remove(logPath)
|
||||||
|
os.RemoveAll(snapshotPath)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if file, err := os.Open(infoPath); err == nil {
|
if file, err := os.Open(infoPath); err == nil {
|
||||||
if content, err := ioutil.ReadAll(file); err != nil {
|
if content, err := ioutil.ReadAll(file); err != nil {
|
||||||
fatal("Unable to read info: %v", err)
|
fatal("Unable to read info: %v", err)
|
||||||
|
Reference in New Issue
Block a user