-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
89 lines (79 loc) · 2.43 KB
/
Copy pathmain.go
File metadata and controls
89 lines (79 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package main
import (
"embed"
"flag"
"io"
"log"
"os"
"github.com/wailsapp/wails/v2"
"github.com/wailsapp/wails/v2/pkg/options"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"github.com/wailsapp/wails/v2/pkg/options/linux"
"github.com/wailsapp/wails/v2/pkg/options/mac"
)
//go:embed all:frontend/dist
var assets embed.FS
//go:embed services/**/*.yml
var serviceFiles embed.FS
//go:embed build/appicon.png
var appIcon []byte
//go:embed trayicons/solarized-sun.png
var trayIcon []byte
func main() {
// Dual-role binary: with --daemon (or -daemon) the SAME executable runs headless —
// no Wails window, tray or webview — bringing the core engine (native-earner
// supervisor + loopback fleet API + scheduler) up so an OS service manager can keep
// earners alive after the GUI is closed (see docs/NATIVE-SUPERVISION.md, Phase A).
// Without the flag it is the normal GUI app, unchanged.
//
// Parse with a private ContinueOnError FlagSet whose errors/usage are discarded,
// never the default ExitOnError parser: a GUI launch (Finder / Wails) may carry OS
// args we do not define (e.g. a macOS -psn_… process serial), and those must fall
// through to wails.Run rather than exit(2) the process. flag.Parse never mutates
// os.Args, so Wails still sees the full argument list.
fs := flag.NewFlagSet("cashpilot-desktop", flag.ContinueOnError)
fs.SetOutput(io.Discard)
daemon := fs.Bool("daemon", false, "run headless: supervise native earners and serve the loopback fleet API with no GUI window")
_ = fs.Parse(os.Args[1:])
if *daemon {
if err := runDaemon(); err != nil {
log.Fatal(err)
}
return
}
app := NewApp()
app.trayIcon = trayIcon
err := wails.Run(&options.App{
Title: "CashPilot Desktop",
Width: 1200,
Height: 800,
MinWidth: 900,
MinHeight: 640,
Frameless: true,
BackgroundColour: options.NewRGB(6, 6, 15),
AssetServer: &assetserver.Options{
Assets: assets,
},
OnStartup: app.Startup,
OnDomReady: app.DomReady,
OnShutdown: app.Shutdown,
Mac: &mac.Options{
Appearance: mac.NSAppearanceNameDarkAqua,
About: &mac.AboutInfo{
Title: "CashPilot Desktop",
Message: "Local-first passive income and DePIN service manager",
Icon: appIcon,
},
},
Linux: &linux.Options{
Icon: appIcon,
ProgramName: "CashPilot Desktop",
},
Bind: []interface{}{
app,
},
})
if err != nil {
log.Fatal(err)
}
}