forked from urdt/ussd
added code to reset the state and persist it
This commit is contained in:
parent
e8c171a82e
commit
50c006546c
@ -53,25 +53,24 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the persister
|
|
||||||
|
|
||||||
// get the state
|
|
||||||
|
|
||||||
// restart the state
|
|
||||||
|
|
||||||
// persist the state
|
|
||||||
|
|
||||||
// exit
|
|
||||||
|
|
||||||
st := pe.GetState()
|
st := pe.GetState()
|
||||||
|
|
||||||
if st == nil {
|
if st == nil {
|
||||||
logg.ErrorCtxf(ctx, "state fail in devtool", "state", st)
|
logg.ErrorCtxf(ctx, "state fail in devtool", "state", st)
|
||||||
fmt.Errorf("cannot get state")
|
fmt.Println("cannot get state")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
st.Restart()
|
fmt.Println("The state:", st)
|
||||||
|
|
||||||
|
// set empty Code to allow the menu to run from the top
|
||||||
|
st.Code = []byte{}
|
||||||
|
|
||||||
|
err = pe.Save(sessionId)
|
||||||
|
if err != nil {
|
||||||
|
logg.ErrorCtxf(ctx, "failed to persist the state and cache", "error", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user