*
Jes Olson j3s@c3f.net
Thu, 26 Dec 2024 22:25:56 -0500
4 files changed,
20 insertions(+),
38 deletions(-)
M
internal/assets/overview.tmpl
→
internal/assets/overview.tmpl
@@ -76,14 +76,6 @@ </div>
<div class="col-md-12"> - -<h2>storage</h2> - -<h2>private network addresses</h2> - -<h2>public network addresses</h2> - - </div> </div>
M
main.go
→
main.go
@@ -4,21 +4,34 @@ import (
"log" "net/http" "os/exec" + "path/filepath" "j3s.sh/gore/internal/assets" ) +func newService(path string) *service { + s := &service{ + cmd: exec.Command(path), + stopped: false, + } + + s.state = NewProcessState() + + tag := filepath.Base(s.Cmd().Path) + s.Stdout = newLogWriter(tag) + s.Stderr = newLogWriter(tag) + + return s +} + func main() { http.HandleFunc("GET /", indexHandler) http.Handle("GET /assets/", http.StripPrefix("/assets/", http.FileServer(http.FS(assets.Assets)))) http.HandleFunc("POST /add", addHandler) var services []*service - var service1 = &service{ - cmd: exec.Command("/home/j3s/code/gore/builddir/git.j3s.sh/vore@v0.0.0-20240814184024-9d6fb2a0444f/vore"), - } - service1.state = NewProcessState() - services = append(services, service1) + s1 := newService("/home/j3s/code/gore/builddir/git.j3s.sh/vore@v0.0.0-20240814184024-9d6fb2a0444f/vore") + services = append(services, s1) if err := SuperviseServices(services); err != nil { log.Fatal(err)
M
supervise.go
→
supervise.go
@@ -203,8 +203,6 @@
supervisionMu sync.Mutex supervision supervisionMode - waitForClock bool - state *processState }@@ -404,15 +402,6 @@ log.Printf("cannot read module info from %s: %v", s.Cmd().Path, err)
} attempt := 0 - - // Wait for clock to be updated via ntp for services - // that need correct time. This can be enabled - // by adding a settings file named waitforclock.txt under - // waitforclock/<package> directory. - if strings.HasPrefix(s.Cmd().Path, "/user/") && s.waitForClock { - log.Print("gore: waiting for clock to be synced") - WaitForClock() - } for { if s.Stopped() {@@ -684,22 +673,10 @@ services.Lock()
services.S = svc defer services.Unlock() for _, s := range services.S { - fmt.Println(s) + fmt.Printf("%+v", s) go supervise(s) } http.HandleFunc("POST /stop", stopstartHandler) http.HandleFunc("POST /restart", stopstartHandler) } - -func WaitForClock() { - epochPlus1Year := time.Unix(60*60*24*365, 0) - for { - if time.Now().After(epochPlus1Year) { - return - } - // Sleeps for 1 real second, regardless of wall-clock time. - // See https://github.com/golang/proposal/blob/master/design/12914-monotonic.md - time.Sleep(1 * time.Second) - } -}