Mining/cmd/desktop/mining-desktop/main.go
snider ab47bae0a3 feat: Add CPU throttling, settings manager, and multi-miner tests
- Add CPUMaxThreadsHint, priority, pause-on-active/battery to XMRig config
- Create SettingsManager for app preferences (window state, miner defaults)
- Add settings API to desktop app service (GetSettings, SaveWindowState, etc)
- Create throttle_test.go with multi-miner CPU usage verification tests
- Create settings_manager_test.go with concurrent access tests
- Desktop app now remembers window size between launches

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 16:35:02 +00:00

82 lines
1.8 KiB
Go

package main
import (
"embed"
_ "embed"
"io/fs"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed all:frontend/dist/browser
var assets embed.FS
func main() {
// Create the mining service
miningService := NewMiningService()
// Get the sub-filesystem rooted at frontend/dist/browser
browserFS, err := fs.Sub(assets, "frontend/dist/browser")
if err != nil {
log.Fatal("Failed to create sub-filesystem:", err)
}
// Create a new Wails application
app := application.New(application.Options{
Name: "Mining Dashboard",
Description: "Multi-miner management dashboard",
Services: []application.Service{
application.NewService(miningService),
},
Assets: application.AssetOptions{
Handler: http.FileServer(http.FS(browserFS)),
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Get saved window state
windowState := miningService.GetWindowState()
width := windowState.Width
height := windowState.Height
if width == 0 {
width = 1400
}
if height == 0 {
height = 900
}
// Create the main window with saved dimensions
app.Window.NewWithOptions(application.WebviewWindowOptions{
Title: "Mining Dashboard",
Width: width,
Height: height,
Mac: application.MacWindow{
InvisibleTitleBarHeight: 50,
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
},
BackgroundColour: application.NewRGB(10, 10, 18),
URL: "/",
})
// Handle graceful shutdown
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigChan
miningService.Shutdown()
os.Exit(0)
}()
// Run the application
if err := app.Run(); err != nil {
log.Fatal(err)
}
}