mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
fix(display): closing app wont stop server
This commit is contained in:
+11
-2
@@ -4,6 +4,7 @@ import (
|
|||||||
"log/slog"
|
"log/slog"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"plg-mudics/control/frontend"
|
"plg-mudics/control/frontend"
|
||||||
"plg-mudics/shared"
|
"plg-mudics/shared"
|
||||||
@@ -28,11 +29,19 @@ func main() {
|
|||||||
|
|
||||||
port := "8080"
|
port := "8080"
|
||||||
|
|
||||||
go shared.OpenBrowserWindow("http://localhost:"+port, false, false)
|
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
||||||
|
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
|
||||||
|
go func() {
|
||||||
err := e.Start(":" + port)
|
err := e.Start(":" + port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to start Echo Webserver", "error", err)
|
slog.Error("Failed to start Echo Webserver", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
err := shared.OpenBrowserWindow("http://localhost:"+port, false, false)
|
||||||
|
if err != nil {
|
||||||
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -24,8 +24,10 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
port := "1323"
|
port := "1323"
|
||||||
go web.StartWebServer(VERSION, port)
|
|
||||||
|
|
||||||
|
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
||||||
|
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
|
||||||
|
go web.StartWebServer(VERSION, port)
|
||||||
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to open browser window", "error", err)
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user