Now have a simple tester .exe that will do various start/stop/run patterns and then used that to sort out how to monitor the processes and keep them running. Next is to add process monitoring and a way to signal ozai to stop something.

master
Zed A. Shaw 3 days ago
parent 0c9bfe2f76
commit 1ba7fc14ff
  1. 12
      .ozai.json
  2. 5
      Makefile
  3. 1
      config/settings.go
  4. 2
      go.mod
  5. 2
      go.sum
  6. 20
      main.go
  7. 18
      tools/cmd/tester/main.go

@ -1,8 +1,14 @@
{
"Processes": {
"ssgod": {
"Name": "ssgod",
"Command": "ssgod"
"tester1": {
"Name": "tester",
"Command": "tester",
"Args": ["-count", "2", "-id", "1"]
},
"tester2": {
"Name": "tester",
"Command": "tester",
"Args": ["-count", "5", "-id", "2"]
}
}
}

@ -4,13 +4,16 @@ ifeq '$(OS)' 'Windows_NT'
GO_IS_STUPID_EXE=.exe
endif
build:
build: build_tester
go build .
test:
go test lcthw.dev/learn-code-the-hard-way/ozai/tests -c -o runtests$(GO_IS_STUPID_EXE)
./runtests$(GO_IS_STUPID_EXE)
build_tester:
go build -o tester$(GO_IS_STUPID_EXE) ./tools/cmd/tester/main.go
docs:
go tool pkgsite --open

@ -10,6 +10,7 @@ import (
type command struct {
Command string
Args []string
}
type config struct {

@ -2,8 +2,6 @@ module lcthw.dev/learn-code-the-hard-way/ozai
go 1.24.2
require github.com/BurntSushi/toml v1.5.0
require (
github.com/google/licensecheck v0.3.1 // indirect
github.com/google/safehtml v0.0.3-0.20211026203422-d6f0e11a5516 // indirect

@ -1,5 +1,3 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/licensecheck v0.3.1 h1:QoxgoDkaeC4nFrtGN1jV7IPmDCHFNIVh54e5hSt6sPs=

@ -5,6 +5,7 @@ import (
"os/exec"
"log"
"errors"
"sync"
"lcthw.dev/learn-code-the-hard-way/ozai/config"
)
@ -13,8 +14,18 @@ func main() {
fmt.Println("CONFIG:", config.Settings.ConfigPath)
fmt.Println("COMMANDs:", config.Settings.Processes)
var wg sync.WaitGroup
cmd := exec.Command(config.Settings.Processes["ssgod"].Command)
for name, proc := range config.Settings.Processes {
fmt.Println("PROCESS:", name)
wg.Add(1)
go func() {
defer wg.Done()
for {
fmt.Println("STARTING", name)
cmd := exec.Command(proc.Command, proc.Args...)
if errors.Is(cmd.Err, exec.ErrDot) {
cmd.Err = nil
}
@ -26,5 +37,12 @@ func main() {
log.Fatal(err)
}
fmt.Println("WAITING for", name)
cmd.Wait()
fmt.Println("PROC", name, "EXITED SEND QUIT")
}
}()
}
wg.Wait()
}

@ -0,0 +1,18 @@
package main
import (
"fmt"
"time"
"flag"
)
func main() {
count := flag.Int("count", 10, "Seconds to wait")
id := flag.Int("id", 1, "Tester ID to use.")
for i := 0; i < *count; i++ {
time.Sleep(1 * time.Second)
fmt.Println("TICK", *id)
}
}
Loading…
Cancel
Save