mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-06 10:01:06 +08:00

* Add service registration method * Fix error handling and formatting in messageprocessor * Add configurable error handling * Improve error strings * Fix service shutdown on macOS * Add post shutdown hook * Better fatal errors * Add startup/shutdown sequence tests * Improve debug messages * Update JS runtime * Update docs * Update changelog * Fix log message in clipboard message processor Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Remove panic in RegisterService * Fix linux tests (hopefully) * Fix error formatting everywhere * Fix typo in windows webview * Tidy example mods * Set application name in tests * Fix ubuntu test workflow * Cleanup template test pipeline * Fix dev build detection on Go 1.24 * Update template go.mod/sum to Go 1.24 * Remove redundant caching in template tests * Final format string cleanup * Fix wails3 tool references * Fix legacy log calls * Remove formatJS and simplify format strings * Fix indirect import --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
//go:build !production
|
|
|
|
package application
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/wailsapp/wails/v3/internal/assetserver"
|
|
)
|
|
|
|
var devMode = false
|
|
|
|
func (a *App) preRun() error {
|
|
// Check for frontend server url
|
|
frontendURL := assetserver.GetDevServerURL()
|
|
if frontendURL != "" {
|
|
devMode = true
|
|
// We want to check if the frontend server is running by trying to http get the url
|
|
// and if it is not, we wait 500ms and try again for a maximum of 10 times. If it is
|
|
// still not available, we return an error.
|
|
// This is to allow the frontend server to start up before the backend server.
|
|
client := http.Client{}
|
|
a.Logger.Info("Waiting for frontend dev server to start...", "url", frontendURL)
|
|
for i := 0; i < 10; i++ {
|
|
_, err := client.Get(frontendURL)
|
|
if err == nil {
|
|
a.Logger.Info("Connected to frontend dev server!")
|
|
return nil
|
|
}
|
|
// Wait 500ms
|
|
time.Sleep(500 * time.Millisecond)
|
|
if i%2 == 0 {
|
|
a.Logger.Info("Retrying...")
|
|
}
|
|
}
|
|
a.fatal("unable to connect to frontend server. Please check it is running - FRONTEND_DEVSERVER_URL='%s'", frontendURL)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a *App) postQuit() {
|
|
if devMode {
|
|
a.Logger.Info("The application has terminated, but the watcher is still running.")
|
|
a.Logger.Info("To terminate the watcher, press CTRL+C")
|
|
}
|
|
}
|
|
|
|
func (a *App) enableDevTools() {
|
|
|
|
}
|