mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-05 16:37:09 +00:00
fix(control): sometimes could not start browser
This commit is contained in:
Executable
BIN
Binary file not shown.
+1
-1
@@ -64,7 +64,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
err = shared.OpenBrowserWindow("http://localhost:"+port, false, false)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("Failed to open browser window", "error", err)
|
slog.Error("Failed to open browser window", "error", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ func main() {
|
|||||||
// the order is important, the open browser command exitsts as soon as the winodw is closed
|
// 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
|
// and since its the last action in the main go func all other goroutines (e.g. the webserver) are killed
|
||||||
go web.StartWebServer(shared.Version, port)
|
go web.StartWebServer(shared.Version, port)
|
||||||
err = shared.OpenBrowserWindow("http://localhost:"+port, true, true)
|
err = shared.OpenBrowserWindow("http://localhost:"+port, 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)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
|
|||||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||||
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
|
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
|
||||||
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
|
golang.org/x/telemetry v0.0.0-20250710130107-8d8967aff50b/go.mod h1:4ZwOYna0/zsOKwuR5X/m0QFOJpSZvAxFfkQT+Erd9D4=
|
||||||
|
golang.org/x/telemetry v0.0.0-20251111182119-bc8e575c7b54/go.mod h1:hKdjCMrbv9skySur+Nek8Hd0uJ0GuxJIoIX2payrIdQ=
|
||||||
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ=
|
||||||
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
|
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
|
||||||
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
|
golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg=
|
||||||
|
|||||||
+6
-10
@@ -7,21 +7,17 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func OpenBrowserWindow(url string, fullscreen bool, temp bool) error {
|
func OpenBrowserWindow(url string, fullscreen bool) error {
|
||||||
bins := []string{"chromium", "chromium-browser"}
|
bins := []string{"chromium", "chromium-browser"}
|
||||||
|
|
||||||
args := []string{fmt.Sprintf("--app=%s", url), "--autoplay-policy=no-user-gesture-required"}
|
tempDirPath, err := os.MkdirTemp("", "plg-mudics-browser-")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
args := []string{fmt.Sprintf("--app=%s", url), "--autoplay-policy=no-user-gesture-required", fmt.Sprintf("--user-data-dir=%s", tempDirPath)}
|
||||||
if fullscreen {
|
if fullscreen {
|
||||||
args = append(args, "--start-fullscreen")
|
args = append(args, "--start-fullscreen")
|
||||||
}
|
}
|
||||||
if temp {
|
|
||||||
tempDirPath, err := os.MkdirTemp("", "plg-mudics-browser-")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
arg := fmt.Sprintf("--user-data-dir=%s", tempDirPath)
|
|
||||||
args = append(args, arg)
|
|
||||||
}
|
|
||||||
|
|
||||||
errs := []string{}
|
errs := []string{}
|
||||||
for _, bin := range bins {
|
for _, bin := range bins {
|
||||||
|
|||||||
Reference in New Issue
Block a user