~louis77/gemini.tunerapp.org

daf767fa1e449e24d239ae980706a395967b2158 — Louis Brauer 11 months ago 856a5a8 main
handle frequent panics from goradios
1 files changed, 8 insertions(+), 0 deletions(-)

M main.go
M main.go => main.go +8 -0
@@ 19,6 19,7 @@
package main

import (
	"fmt"
	"io"
	"log"
	"strings"


@@ 52,6 53,12 @@ var (
	}
)

func handlePanic() {
	if r := recover(); r != nil {
		fmt.Println("Recovering from panic:", r)
	}
}

func loadData(refresh bool) {
	cacheName := "cache"
	cache := gobcache.NewCache(gobcache.Config{})


@@ 70,6 77,7 @@ func loadData(refresh bool) {
	data.Stations = goradios.FetchAllStationsDetailed(goradios.StationsOrderName, false, 0, 0, true)

	go func() {
		defer handlePanic()
		for {
			log.Println("... top 5 stations with refresh every minute")
			data.Top5Stations = goradios.FetchAllStationsDetailed(goradios.StationsOrderLastCheckTime, true, 0, 5, true)