first commit
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"sproutclaw-web/internal/config"
|
||||
@@ -18,11 +17,10 @@ import (
|
||||
func main() {
|
||||
cfg := config.New()
|
||||
|
||||
log.Printf("[sproutclaw-web] port=%d agent-dir=%s", cfg.Port, cfg.AgentDir)
|
||||
log.Printf("[sproutclaw-web] port=%d agent-dir=%s repo-root=%s", cfg.Port, cfg.AgentDir, cfg.RepoRoot)
|
||||
|
||||
// Database (stores in agent data dir)
|
||||
dataDir := filepath.Join(cfg.AgentDir, "data", "sproutclaw-web")
|
||||
database, err := db.Init(dataDir)
|
||||
// Database (stores in backend/data)
|
||||
database, err := db.Init(cfg.DataDir)
|
||||
if err != nil {
|
||||
log.Fatalf("db init: %v", err)
|
||||
}
|
||||
@@ -30,7 +28,7 @@ func main() {
|
||||
log.Printf("[sproutclaw-web] db: %s", database.DbPath)
|
||||
|
||||
// pi CLI RPC client
|
||||
piClient, err := rpc.NewClient(cfg.PiCmd, cfg.PiArgs, cfg.AgentDir, func(code int) {
|
||||
piClient, err := rpc.NewClient(cfg.PiCmd, cfg.PiArgs, cfg.RepoRoot, cfg.AgentDir, func(code int) {
|
||||
if code != 0 {
|
||||
log.Printf("[sproutclaw-web] pi CLI exited with code %d, shutting down", code)
|
||||
os.Exit(1)
|
||||
@@ -56,13 +54,14 @@ func main() {
|
||||
handlers.RegisterCommands(api, cfg)
|
||||
handlers.RegisterWebuiConfig(api, database)
|
||||
handlers.RegisterSettings(api, cfg, database, piClient)
|
||||
handlers.RegisterTerminal(api, cfg)
|
||||
handlers.RegisterExtensionUI(api, piClient)
|
||||
|
||||
// Static files (production: frontend/dist/)
|
||||
static.Register(r, cfg.FrontendDist)
|
||||
|
||||
addr := fmt.Sprintf("0.0.0.0:%d", cfg.Port)
|
||||
log.Printf("[sproutclaw-web] listening on http://localhost:%d", cfg.Port)
|
||||
log.Printf("[sproutclaw-web] listening on http://0.0.0.0:%d (LAN: http://<本机IP>:%d)", cfg.Port, cfg.Port)
|
||||
if err := r.Run(addr); err != nil {
|
||||
log.Fatalf("server: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user