Win app: defer cleanup
This commit is contained in:
parent
1a006f47a0
commit
dae99c99a1
1 changed files with 15 additions and 7 deletions
22
win/main.go
22
win/main.go
|
@ -53,14 +53,26 @@ func main() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
cmd := runServer(ctx)
|
cmd := runServer(ctx)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
fmt.Println("Cleanup")
|
||||||
|
cancel()
|
||||||
|
if err := cmd.Process.Kill(); err != nil {
|
||||||
|
log.Fatal("failed to kill server process: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
log.Fatal("ERROR: ", r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
ui, err := lorca.New("", "", 1024, 768)
|
ui, err := lorca.New("", "", 1024, 768)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
// defer ui.Close()
|
defer ui.Close()
|
||||||
|
|
||||||
if err := ui.Load("http://localhost:8088"); err != nil {
|
if err := ui.Load("http://localhost:8088"); err != nil {
|
||||||
log.Fatal(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
script := fmt.Sprintf("localStorage.setItem('sessionId', '%s');", sessionToken)
|
script := fmt.Sprintf("localStorage.setItem('sessionId', '%s');", sessionToken)
|
||||||
|
@ -73,10 +85,6 @@ func main() {
|
||||||
<-ui.Done()
|
<-ui.Done()
|
||||||
|
|
||||||
log.Printf("App Closed")
|
log.Printf("App Closed")
|
||||||
cancel()
|
|
||||||
if err := cmd.Process.Kill(); err != nil {
|
|
||||||
log.Fatal("failed to kill process: ", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func hideConsole() {
|
func hideConsole() {
|
||||||
|
|
Loading…
Reference in a new issue