added some code to exit the whole process upon panic in http goroutines
This commit is contained in:
10
hodu.go
10
hodu.go
@ -1,5 +1,8 @@
|
||||
package hodu
|
||||
|
||||
import "net/http"
|
||||
import "os"
|
||||
import "runtime"
|
||||
import "sync"
|
||||
|
||||
const HODU_RPC_VERSION uint32 = 0x010000
|
||||
@ -39,3 +42,10 @@ func tcp_addr_str_class(addr string) string {
|
||||
|
||||
return "tcp"
|
||||
}
|
||||
|
||||
func dump_call_frame_and_exit(log Logger, req *http.Request, err interface{}) {
|
||||
var buf []byte
|
||||
buf = make([]byte, 65536); buf = buf[:min(65536, runtime.Stack(buf, false))]
|
||||
log.Write("", LOG_ERROR, "[%s] %s %s - %v\n%s", req.RemoteAddr, req.Method, req.URL.String(), err, string(buf))
|
||||
os.Exit(99) // fatal error. treat panic() as a fatal runtime error
|
||||
}
|
||||
|
Reference in New Issue
Block a user