Commit ed40b196 authored by szh's avatar szh

make sure after exec close bty is stop

parent 9a230a54
......@@ -22,7 +22,10 @@ func RaspberryChan() {
if value.Name == "" {
continue
}
btyPath = GetAbsPath(setting.BityuanSetting.Name)
path := GetAbsPath(setting.BityuanSetting.Name)
if path != "" {
btyPath = path
}
switch value.Name {
case "ROLLBACK":
err := rollback()
......@@ -85,7 +88,11 @@ func rollback() error {
if (pai.LocalLastHeight - 1000) <= 0 {
rollheight = 1
}
time.Sleep(time.Second * 2)
isrun := MakeSureBtyIsNotRun()
if isrun {
BityuanFlag.Flag = false
return errors.New("bty is running")
}
tlog.Info("rollback start","height",pai.LocalLastHeight,"rollbackheight",rollheight)
var buf bytes.Buffer
if btyPath == "" {
......@@ -122,7 +129,11 @@ func backup() error {
BityuanFlag.Flag = false
return errors.New("env err")
}
time.Sleep(time.Second * 2)
isrun := MakeSureBtyIsNotRun()
if isrun {
BityuanFlag.Flag = false
return errors.New("bty is running")
}
return SafeBackup()
}
......@@ -187,4 +198,14 @@ func deleteBackup() error {
return err
}
return nil
}
func MakeSureBtyIsNotRun() bool {
for {
info := getProcessInfo(setting.BityuanSetting.Name)
if info == "" {
return false
}
}
return true
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment