mirror of https://github.com/hashicorp/consul
command: automatically migrate raft data on start
parent
ed67f6593f
commit
ac0f66a91e
|
@ -15,6 +15,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/armon/go-metrics"
|
"github.com/armon/go-metrics"
|
||||||
|
"github.com/hashicorp/consul-migrate/migrator"
|
||||||
"github.com/hashicorp/consul/watch"
|
"github.com/hashicorp/consul/watch"
|
||||||
"github.com/hashicorp/go-checkpoint"
|
"github.com/hashicorp/go-checkpoint"
|
||||||
"github.com/hashicorp/go-syslog"
|
"github.com/hashicorp/go-syslog"
|
||||||
|
@ -597,6 +598,28 @@ func (c *Command) Run(args []string) int {
|
||||||
metrics.NewGlobal(metricsConf, inm)
|
metrics.NewGlobal(metricsConf, inm)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are starting a consul 0.5.1+ server for the first time,
|
||||||
|
// and we have data from a previous Consul version, attempt to
|
||||||
|
// migrate the data from LMDB to BoltDB using the migrator utility.
|
||||||
|
if config.Server {
|
||||||
|
m, err := migrator.New(config.DataDir)
|
||||||
|
if err != nil {
|
||||||
|
c.Ui.Error(err.Error())
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
start := time.Now()
|
||||||
|
migrated, err := m.Migrate()
|
||||||
|
if err != nil {
|
||||||
|
c.Ui.Error(fmt.Sprintf("Failed to migrate raft data: %s", err))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
if migrated {
|
||||||
|
duration := time.Now().Sub(start)
|
||||||
|
c.Ui.Output(fmt.Sprintf("Successfully migrated raft data in %s", duration))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the agent
|
// Create the agent
|
||||||
if err := c.setupAgent(config, logOutput, logWriter); err != nil {
|
if err := c.setupAgent(config, logOutput, logWriter); err != nil {
|
||||||
return 1
|
return 1
|
||||||
|
|
Loading…
Reference in New Issue