summaryrefslogtreecommitdiff
path: root/internal/app/app.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-13 22:52:46 +0200
committerPaul Buetow <paul@buetow.org>2026-02-13 22:52:46 +0200
commitcd5a3614baab756a41d764b79308afeea93f12dd (patch)
treeefc8c31e8b162ca2121ba92c841322119e6d3b04 /internal/app/app.go
parentbf7c6ade292a6444877797c8d699d147aceb57cc (diff)
Remove Perl version and build files; add .gitignore for .serena/
Amp-Thread-ID: https://ampcode.com/threads/T-019c58b3-06fb-733d-8fc1-f268fe7f70d5 Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'internal/app/app.go')
-rw-r--r--internal/app/app.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
new file mode 100644
index 0000000..946e985
--- /dev/null
+++ b/internal/app/app.go
@@ -0,0 +1,35 @@
+package app
+
+import (
+ "context"
+ "sync"
+
+ "github.com/loadbars/loadbars/internal/collector"
+ "github.com/loadbars/loadbars/internal/config"
+ "github.com/loadbars/loadbars/internal/display"
+)
+
+// Run starts the loadbars application: collectors and display.
+// It blocks until the user quits (e.g. 'q' key).
+func Run(cfg *config.Config) error {
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ scriptPath := ScriptPath()
+ store := NewStore()
+
+ var wg sync.WaitGroup
+ for _, host := range cfg.Hosts {
+ h := host
+ wg.Add(1)
+ go func() {
+ defer wg.Done()
+ _ = collector.Run(ctx, h, cfg, store, scriptPath)
+ }()
+ }
+
+ err := display.Run(ctx, cfg, store)
+ cancel()
+ wg.Wait()
+ return err
+}