don't report errors when the backend is expected to die
This commit is contained in:
parent
e8ee70d0f0
commit
9f878bffde
22
backend.go
22
backend.go
|
@ -23,7 +23,10 @@ import (
|
||||||
"net/rpc"
|
"net/rpc"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"humungus.tedunangst.com/r/webs/gate"
|
"humungus.tedunangst.com/r/webs/gate"
|
||||||
"humungus.tedunangst.com/r/webs/image"
|
"humungus.tedunangst.com/r/webs/image"
|
||||||
|
@ -112,6 +115,7 @@ func orphancheck() {
|
||||||
func backendServer() {
|
func backendServer() {
|
||||||
dlog.Printf("backend server running")
|
dlog.Printf("backend server running")
|
||||||
go orphancheck()
|
go orphancheck()
|
||||||
|
signal.Ignore(syscall.SIGINT)
|
||||||
shrinker := new(Shrinker)
|
shrinker := new(Shrinker)
|
||||||
srv := rpc.NewServer()
|
srv := rpc.NewServer()
|
||||||
err := srv.Register(shrinker)
|
err := srv.Register(shrinker)
|
||||||
|
@ -152,9 +156,23 @@ func runBackendServer() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
elog.Panicf("can't exec backend: %s", err)
|
elog.Panicf("can't exec backend: %s", err)
|
||||||
}
|
}
|
||||||
|
workinprogress++
|
||||||
|
var mtx sync.Mutex
|
||||||
|
go func() {
|
||||||
|
<-endoftheworld
|
||||||
|
mtx.Lock()
|
||||||
|
defer mtx.Unlock()
|
||||||
|
w.Close()
|
||||||
|
w = nil
|
||||||
|
readyalready <- true
|
||||||
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
proc.Wait()
|
proc.Wait()
|
||||||
elog.Printf("lost the backend: %s", err)
|
mtx.Lock()
|
||||||
w.Close()
|
defer mtx.Unlock()
|
||||||
|
if w != nil {
|
||||||
|
elog.Printf("lost the backend: %s", err)
|
||||||
|
w.Close()
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
2
web.go
2
web.go
|
@ -2556,7 +2556,7 @@ var workinprogress = 0
|
||||||
|
|
||||||
func enditall() {
|
func enditall() {
|
||||||
sig := make(chan os.Signal)
|
sig := make(chan os.Signal)
|
||||||
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGQUIT)
|
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
||||||
<-sig
|
<-sig
|
||||||
ilog.Printf("stopping...")
|
ilog.Printf("stopping...")
|
||||||
for i := 0; i < workinprogress; i++ {
|
for i := 0; i < workinprogress; i++ {
|
||||||
|
|
Loading…
Reference in New Issue