all repos — honk @ a4a544d24ae5d125c4f6578f103cbccfbdcfacce

my fork of honk

don't report errors when the backend is expected to die
Ted Unangst tedu@tedunangst.com
Wed, 21 Jun 2023 01:08:13 -0400
commit

a4a544d24ae5d125c4f6578f103cbccfbdcfacce

parent

058701b1e5190dc5ab1b97aff801211d6173e012

2 files changed, 21 insertions(+), 3 deletions(-)

jump to
M backend.gobackend.go

@@ -23,7 +23,10 @@ "net/http"

"net/rpc" "os" "os/exec" + "os/signal" "strings" + "sync" + "syscall" "humungus.tedunangst.com/r/webs/gate" "humungus.tedunangst.com/r/webs/image"

@@ -112,6 +115,7 @@

func backendServer() { dlog.Printf("backend server running") go orphancheck() + signal.Ignore(syscall.SIGINT) shrinker := new(Shrinker) srv := rpc.NewServer() err := srv.Register(shrinker)

@@ -152,9 +156,23 @@ err = proc.Start()

if err != nil { elog.Panicf("can't exec backend: %s", err) } + workinprogress++ + var mtx sync.Mutex go func() { - proc.Wait() - elog.Printf("lost the backend: %s", err) + <-endoftheworld + mtx.Lock() + defer mtx.Unlock() w.Close() + w = nil + readyalready <- true + }() + go func() { + proc.Wait() + mtx.Lock() + defer mtx.Unlock() + if w != nil { + elog.Printf("lost the backend: %s", err) + w.Close() + } }() }
M web.goweb.go

@@ -2556,7 +2556,7 @@ var workinprogress = 0

func enditall() { sig := make(chan os.Signal) - signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT) + signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) <-sig ilog.Printf("stopping...") for i := 0; i < workinprogress; i++ {