Skip to content

Commit

Permalink
continue after process kill panic
Browse files Browse the repository at this point in the history
  • Loading branch information
tzerk committed Feb 27, 2017
1 parent 8735a55 commit 0edb12c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"gopkg.in/yaml.v2"
"io/ioutil"
"syscall"
"fmt"
)

// Telegram and program settings (config.yml)
Expand Down Expand Up @@ -41,7 +42,7 @@ func main() {
//--------------------------------------------------------------------------------------------------------------
// YAML PARSING
var config Config
source, err := ioutil.ReadFile("config.yml")
source, err := ioutil.ReadFile("./config.yml")
if err != nil {
// in theory, using yml.Marshal() would be more elegant, but we want to preserve the yaml comments
// as well as set some default values/hints
Expand All @@ -61,7 +62,7 @@ func main() {
"killondc: true\r\n" +
"shutdownondc: false\r\n" +
"killcoherentui: false"
ioutil.WriteFile("config.yml", []byte(defconf), os.FileMode(int(0666)))
ioutil.WriteFile("config.yml", []byte(defconf), os.FileMode(int(0777)))
panic(err)
}
err = yaml.Unmarshal(source, &config)
Expand Down Expand Up @@ -136,10 +137,7 @@ func observer(
log.Println(err)
}
// Kill the process
kill_err := proc.Kill()
if kill_err != nil {
log.Println(err)
}
defer proc.Kill()
}
}
}
Expand Down Expand Up @@ -171,10 +169,7 @@ func observer(
log.Println(err)
}
// Kill the process
kill_err := proc.Kill()
if kill_err != nil {
log.Println(err)
}
defer proc.Kill()

time.Sleep(5 * time.Second)
}
Expand Down Expand Up @@ -264,6 +259,7 @@ func wait(config Config, label_Update *ui.Label, pb *ui.ProgressBar) {
} // otherwise division by 0
for i := 0; i <= tstep; i++ {
pb.SetValue(int(100/float32(tstep) * float32(i + 1)))
fmt.Println(tstep, ", ", i, " = ", int32(100/float32(tstep) * float32(i + 1)))
label_Update.SetText(" Next update in... " + strconv.Itoa(tstep - i) + " s")
time.Sleep(1 * time.Second)
}
Expand Down

1 comment on commit 0edb12c

@tzerk
Copy link
Owner Author

@tzerk tzerk commented on 0edb12c Feb 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to #4

Please sign in to comment.