54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"git.ourworld.tf/herocode/heroagent/pkg/heroagent"
|
|
"git.ourworld.tf/herocode/heroagent/pkg/servers/ui" // Import the new UI package
|
|
)
|
|
|
|
func main() {
|
|
// Parse command-line flags
|
|
portFlag := flag.String("port", "", "Port to run the HeroLauncher on")
|
|
uiPortFlag := flag.String("uiport", "3000", "Port to run the UI server on") // New flag for UI port
|
|
flag.Parse()
|
|
|
|
// Initialize HeroLauncher with default configuration
|
|
config := heroagent.DefaultConfig()
|
|
|
|
// Override with command-line flags if provided
|
|
if *portFlag != "" {
|
|
config.Port = *portFlag
|
|
}
|
|
|
|
// Override with environment variables if provided
|
|
if port := os.Getenv("PORT"); port != "" {
|
|
config.Port = port
|
|
}
|
|
|
|
// Create HeroLauncher instance
|
|
launcher := heroagent.New(config)
|
|
|
|
// Initialize and start the UI server in a new goroutine
|
|
go func() {
|
|
uiApp := ui.NewApp(ui.AppConfig{}) // Assuming default AppConfig is fine
|
|
uiPort := *uiPortFlag
|
|
if envUiPort := os.Getenv("UIPORT"); envUiPort != "" {
|
|
uiPort = envUiPort
|
|
}
|
|
fmt.Printf("Starting UI server on port %s...\n", uiPort)
|
|
if err := uiApp.Listen(":" + uiPort); err != nil {
|
|
log.Printf("Failed to start UI server: %v", err) // Use Printf to not exit main app
|
|
}
|
|
}()
|
|
|
|
// Start the main HeroLauncher server
|
|
fmt.Printf("Starting HeroLauncher on port %s...\n", config.Port)
|
|
if err := launcher.Start(); err != nil {
|
|
log.Fatalf("Failed to start HeroLauncher: %v", err)
|
|
}
|
|
}
|