mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
implement draft/webpush (#2205)
This commit is contained in:
parent
efd3764337
commit
36e5451aa5
44 changed files with 2091 additions and 100 deletions
|
|
@ -6,14 +6,19 @@ package irc
|
|||
import (
|
||||
"fmt"
|
||||
"runtime/debug"
|
||||
"time"
|
||||
)
|
||||
|
||||
// HandlePanic is a general-purpose panic handler for ad-hoc goroutines.
|
||||
// Because of the semantics of `recover`, it must be called directly
|
||||
// from the routine on whose call stack the panic would occur, with `defer`,
|
||||
// e.g. `defer server.HandlePanic()`
|
||||
func (server *Server) HandlePanic() {
|
||||
func (server *Server) HandlePanic(restartable func()) {
|
||||
if r := recover(); r != nil {
|
||||
server.logger.Error("internal", fmt.Sprintf("Panic encountered: %v\n%s", r, debug.Stack()))
|
||||
if restartable != nil {
|
||||
time.Sleep(time.Second)
|
||||
go restartable()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue