From 02f0d904dee18dcae97b38a47e60b8f2a8573af4 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Wed, 24 Dec 2025 22:51:47 -0500 Subject: [PATCH] Brought more of ozai over to get started. --- .ttarpit.json | 18 ++++++++++++++++++ main.go | 10 ++++++++-- tools/cmd/tester/main.go | 8 +++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.ttarpit.json b/.ttarpit.json index acb258d..4c2b85d 100644 --- a/.ttarpit.json +++ b/.ttarpit.json @@ -4,5 +4,23 @@ "Command": "tester", "Args": ["-count", "100", "-id", "1"] } + }, + "Processes": { + "tester2": { + "Command": "tester", + "Args": ["-count", "100", "-id", "2"] + } + }, + "Processes": { + "tester3": { + "Command": "tester", + "Args": ["-count", "100", "-id", "3"] + } + }, + "Processes": { + "tester4": { + "Command": "tester", + "Args": ["-count", "100", "-id", "4"] + } } } diff --git a/main.go b/main.go index e56cac2..1182741 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "os" "errors" "lcthw.dev/go/ttarpit/config" + "sync" ) func LaunchLogger(in io.Reader, out io.Writer, err error) { @@ -52,6 +53,8 @@ func LaunchProcess(proc *config.Process) { func main() { config.Load() + var wg sync.WaitGroup + fmt.Println("CONFIG:", config.Settings.ConfigPath) fmt.Println("COMMANDs:", config.Settings.Processes) @@ -59,8 +62,11 @@ func main() { fmt.Println("PROCESS:", name) proc.Ready = make(chan string) - go LaunchProcess(&proc) + wg.Go(func() { + LaunchProcess(&proc) + }) } - + fmt.Println("WAITING....") + wg.Wait() } diff --git a/tools/cmd/tester/main.go b/tools/cmd/tester/main.go index b8917b7..b90ffaf 100644 --- a/tools/cmd/tester/main.go +++ b/tools/cmd/tester/main.go @@ -3,8 +3,10 @@ package main import ( "fmt" "time" + "os" "flag" "sync" + "math/rand" ) func Worker(name string, count int, done chan<- int, stop <-chan int) { @@ -16,7 +18,11 @@ func Worker(name string, count int, done chan<- int, stop <-chan int) { return default: time.Sleep(1 * time.Second) - fmt.Println("TESTER #", name) + if rand.Int() % 2 == 0 { + fmt.Println("TESTER #", name) + } else { + os.Stderr.Write([]byte(fmt.Sprintf("TESTER ERR # %s\n", name))) + } } }