Browse Source

Ensure *_wal_dir exists

pull/310/head
Jae Kwon 8 years ago
parent
commit
2aecb2a4a3
2 changed files with 14 additions and 1 deletions
  1. +8
    -1
      consensus/state.go
  2. +6
    -0
      mempool/mempool.go

+ 8
- 1
consensus/state.go View File

@ -304,8 +304,15 @@ func (cs *ConsensusState) SetPrivValidator(priv *types.PrivValidator) {
func (cs *ConsensusState) OnStart() error { func (cs *ConsensusState) OnStart() error {
cs.BaseService.OnStart() cs.BaseService.OnStart()
err := cs.OpenWAL(cs.config.GetString("cs_wal_dir"))
walDir := cs.config.GetString("cs_wal_dir")
err := EnsureDir(walDir, 0700)
if err != nil { if err != nil {
log.Error("Error ensuring ConsensusState wal dir", "error", err.Error())
return err
}
err = cs.OpenWAL(walDir)
if err != nil {
log.Error("Error loading ConsensusState wal", "error", err.Error())
return err return err
} }


+ 6
- 0
mempool/mempool.go View File

@ -87,8 +87,14 @@ func NewMempool(config cfg.Config, proxyAppConn proxy.AppConnMempool) *Mempool {
func (mem *Mempool) initWAL() { func (mem *Mempool) initWAL() {
walDir := mem.config.GetString("mempool_wal_dir") walDir := mem.config.GetString("mempool_wal_dir")
if walDir != "" { if walDir != "" {
err := EnsureDir(walDir, 0700)
if err != nil {
log.Error("Error ensuring Mempool wal dir", "error", err)
PanicSanity(err)
}
af, err := auto.OpenAutoFile(walDir + "/wal") af, err := auto.OpenAutoFile(walDir + "/wal")
if err != nil { if err != nil {
log.Error("Error opening Mempool wal file", "error", err)
PanicSanity(err) PanicSanity(err)
} }
mem.wal = af mem.wal = af


Loading…
Cancel
Save