init: fuzzygraph app from fn_registry
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
// File logger
|
||||
logFile, err := os.OpenFile("fuzzygraph.log", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
|
||||
if err == nil {
|
||||
log.SetOutput(logFile)
|
||||
defer logFile.Close()
|
||||
}
|
||||
log.SetFlags(log.Ltime | log.Lmicroseconds | log.Lshortfile)
|
||||
|
||||
log.Println("=== fuzzygraph starting ===")
|
||||
log.Printf("cwd: %s", func() string { d, _ := os.Getwd(); return d }())
|
||||
log.Printf("os.Args: %v", os.Args)
|
||||
|
||||
// Resolve projects directory relative to cwd
|
||||
projectsDir := "projects"
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
absProjects := filepath.Join(cwd, "projects")
|
||||
if _, err := os.Stat(absProjects); err == nil {
|
||||
projectsDir = absProjects
|
||||
log.Printf("projectsDir (exists): %s", projectsDir)
|
||||
} else {
|
||||
// Create it
|
||||
os.MkdirAll(absProjects, 0o755)
|
||||
projectsDir = absProjects
|
||||
log.Printf("projectsDir (created): %s", projectsDir)
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve registry root
|
||||
registryRoot := os.Getenv("FN_REGISTRY_ROOT")
|
||||
if registryRoot == "" {
|
||||
if cwd, err := os.Getwd(); err == nil {
|
||||
registryRoot = filepath.Join(cwd, "..", "..")
|
||||
}
|
||||
}
|
||||
log.Printf("registryRoot: %s", registryRoot)
|
||||
log.Printf("registry.db exists: %v", func() bool {
|
||||
_, err := os.Stat(filepath.Join(registryRoot, "registry.db"))
|
||||
return err == nil
|
||||
}())
|
||||
|
||||
app := NewApp(projectsDir, registryRoot)
|
||||
log.Println("App created, starting Wails...")
|
||||
|
||||
runErr := wails.Run(&options.App{
|
||||
Title: "FuzzyGraph — OSINT Intelligence",
|
||||
Width: 1400,
|
||||
Height: 900,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 10, G: 10, B: 15, A: 1},
|
||||
OnStartup: app.startup,
|
||||
OnShutdown: app.shutdown,
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
})
|
||||
|
||||
if runErr != nil {
|
||||
log.Printf("ERROR wails.Run: %v", runErr)
|
||||
fmt.Fprintf(os.Stderr, "error: %v\n", runErr)
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Println("=== fuzzygraph exited cleanly ===")
|
||||
}
|
||||
Reference in New Issue
Block a user