Commit ed40b196 authored by szh's avatar szh

make sure after exec close bty is stop

parent 9a230a54
...@@ -22,7 +22,10 @@ func RaspberryChan() { ...@@ -22,7 +22,10 @@ func RaspberryChan() {
if value.Name == "" { if value.Name == "" {
continue continue
} }
btyPath = GetAbsPath(setting.BityuanSetting.Name) path := GetAbsPath(setting.BityuanSetting.Name)
if path != "" {
btyPath = path
}
switch value.Name { switch value.Name {
case "ROLLBACK": case "ROLLBACK":
err := rollback() err := rollback()
...@@ -85,7 +88,11 @@ func rollback() error { ...@@ -85,7 +88,11 @@ func rollback() error {
if (pai.LocalLastHeight - 1000) <= 0 { if (pai.LocalLastHeight - 1000) <= 0 {
rollheight = 1 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) tlog.Info("rollback start","height",pai.LocalLastHeight,"rollbackheight",rollheight)
var buf bytes.Buffer var buf bytes.Buffer
if btyPath == "" { if btyPath == "" {
...@@ -122,7 +129,11 @@ func backup() error { ...@@ -122,7 +129,11 @@ func backup() error {
BityuanFlag.Flag = false BityuanFlag.Flag = false
return errors.New("env err") 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() return SafeBackup()
} }
...@@ -188,3 +199,13 @@ func deleteBackup() error { ...@@ -188,3 +199,13 @@ func deleteBackup() error {
} }
return nil 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