mirror of https://bitbucket.org/ausocean/av.git
Recover control request panics
When running a go service, especially as a background systemd service, it's not obvious when there is a panic in a handler, so we're now recovering any panics on our level and logging. Approved-by: Alan Noble
This commit is contained in:
parent
d519f50fe5
commit
b992358fd6
|
@ -41,6 +41,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"runtime/debug"
|
||||||
|
|
||||||
"bitbucket.org/ausocean/av/cmd/vidforward/global"
|
"bitbucket.org/ausocean/av/cmd/vidforward/global"
|
||||||
"bitbucket.org/ausocean/av/container/mts"
|
"bitbucket.org/ausocean/av/container/mts"
|
||||||
|
@ -290,7 +291,12 @@ func (m *broadcastManager) recv(w http.ResponseWriter, r *http.Request) {
|
||||||
// control handles control API requests.
|
// control handles control API requests.
|
||||||
func (m *broadcastManager) control(w http.ResponseWriter, r *http.Request) {
|
func (m *broadcastManager) control(w http.ResponseWriter, r *http.Request) {
|
||||||
done := m.dogNotifier.handlerInvoked("control")
|
done := m.dogNotifier.handlerInvoked("control")
|
||||||
defer done()
|
defer func(){
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
m.log.Error("panicked in control request!","error",r.(error).Error(),"stack",string(debug.Stack()))
|
||||||
|
}
|
||||||
|
done()
|
||||||
|
}()
|
||||||
|
|
||||||
m.log.Info("control request", "method", r.Method)
|
m.log.Info("control request", "method", r.Method)
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
|
|
Loading…
Reference in New Issue