- Add parser versioning with Version() method and version display on main screen - Add server model and serial number to Configuration tab and TXT export - Add auto-browser opening on startup with --no-browser flag - Add Restart and Exit buttons with graceful shutdown - Add section overview stats (CPU, Power, Storage, GPU, Network) - Change PCIe Link display to "x16 PCIe Gen4" format - Add Location column to Serials section - Extract BoardInfo from FRU and PlatformId from ThermalConfig Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
79 lines
1.7 KiB
Go
79 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/exec"
|
|
"runtime"
|
|
"time"
|
|
|
|
"git.mchus.pro/mchus/logpile/internal/parser"
|
|
_ "git.mchus.pro/mchus/logpile/internal/parser/vendors" // Register all vendor parsers
|
|
"git.mchus.pro/mchus/logpile/internal/server"
|
|
"git.mchus.pro/mchus/logpile/web"
|
|
)
|
|
|
|
var (
|
|
version = "dev"
|
|
commit = "none"
|
|
)
|
|
|
|
func main() {
|
|
port := flag.Int("port", 8080, "HTTP server port")
|
|
file := flag.String("file", "", "Pre-load archive file")
|
|
showVersion := flag.Bool("version", false, "Show version")
|
|
noBrowser := flag.Bool("no-browser", false, "Don't open browser automatically")
|
|
flag.Parse()
|
|
|
|
if *showVersion {
|
|
fmt.Printf("LOGPile %s (commit: %s)\n", version, commit)
|
|
os.Exit(0)
|
|
}
|
|
|
|
// Set embedded web files
|
|
server.WebFS = web.FS
|
|
|
|
cfg := server.Config{
|
|
Port: *port,
|
|
PreloadFile: *file,
|
|
}
|
|
|
|
srv := server.New(cfg)
|
|
|
|
url := fmt.Sprintf("http://localhost:%d", *port)
|
|
log.Printf("LOGPile starting on %s", url)
|
|
log.Printf("Registered parsers: %v", parser.ListParsers())
|
|
|
|
// Open browser automatically
|
|
if !*noBrowser {
|
|
go func() {
|
|
time.Sleep(500 * time.Millisecond) // Wait for server to start
|
|
openBrowser(url)
|
|
}()
|
|
}
|
|
|
|
if err := srv.Run(); err != nil {
|
|
log.Fatalf("Server error: %v", err)
|
|
}
|
|
}
|
|
|
|
// openBrowser opens the default browser with the given URL
|
|
func openBrowser(url string) {
|
|
var cmd *exec.Cmd
|
|
|
|
switch runtime.GOOS {
|
|
case "darwin":
|
|
cmd = exec.Command("open", url)
|
|
case "windows":
|
|
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
|
|
default: // linux and others
|
|
cmd = exec.Command("xdg-open", url)
|
|
}
|
|
|
|
if err := cmd.Start(); err != nil {
|
|
log.Printf("Failed to open browser: %v", err)
|
|
}
|
|
}
|