more robust end of the world
This commit is contained in:
parent
2b87b84013
commit
370ef66b50
15
web.go
15
web.go
|
@ -983,6 +983,7 @@ func tracker() {
|
||||||
timeout := 4 * time.Minute
|
timeout := 4 * time.Minute
|
||||||
sleeper := time.NewTimer(timeout)
|
sleeper := time.NewTimer(timeout)
|
||||||
tracks := make(map[string][]string)
|
tracks := make(map[string][]string)
|
||||||
|
workinprogress++
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case track := <-trackchan:
|
case track := <-trackchan:
|
||||||
|
@ -2245,25 +2246,19 @@ func apihandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
var endoftheworld = make(chan bool)
|
var endoftheworld = make(chan bool)
|
||||||
var readyalready = make(chan bool)
|
var readyalready = make(chan bool)
|
||||||
|
var workinprogress = 0
|
||||||
|
|
||||||
func enditall() {
|
func enditall() {
|
||||||
sig := make(chan os.Signal)
|
sig := make(chan os.Signal)
|
||||||
signal.Notify(sig, os.Interrupt)
|
signal.Notify(sig, os.Interrupt)
|
||||||
signal.Notify(sig, syscall.SIGTERM)
|
signal.Notify(sig, syscall.SIGTERM)
|
||||||
<-sig
|
<-sig
|
||||||
count := 0
|
|
||||||
log.Printf("stopping...")
|
log.Printf("stopping...")
|
||||||
sendloop:
|
for i := 0; i < workinprogress; i++ {
|
||||||
for {
|
endoftheworld <- true
|
||||||
select {
|
|
||||||
case endoftheworld <- true:
|
|
||||||
count++
|
|
||||||
default:
|
|
||||||
break sendloop
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
log.Printf("waiting...")
|
log.Printf("waiting...")
|
||||||
for i := 0; i < count; i++ {
|
for i := 0; i < workinprogress; i++ {
|
||||||
<-readyalready
|
<-readyalready
|
||||||
}
|
}
|
||||||
log.Printf("apocalypse")
|
log.Printf("apocalypse")
|
||||||
|
|
Loading…
Reference in New Issue