mirror of
https://github.com/kemko/reproxy.git
synced 2026-01-01 15:55:49 +03:00
defer recover
This commit is contained in:
13
app/main.go
13
app/main.go
@@ -160,11 +160,6 @@ func run() error {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
go func() {
|
||||
if x := recover(); x != nil {
|
||||
log.Printf("[WARN] run time panic:\n%v", x)
|
||||
panic(x)
|
||||
}
|
||||
|
||||
// catch signal and invoke graceful termination
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, os.Interrupt, syscall.SIGTERM)
|
||||
@@ -173,6 +168,14 @@ func run() error {
|
||||
cancel()
|
||||
}()
|
||||
|
||||
defer func() {
|
||||
// handle panic
|
||||
if x := recover(); x != nil {
|
||||
log.Printf("[WARN] run time panic:\n%v", x)
|
||||
panic(x)
|
||||
}
|
||||
}()
|
||||
|
||||
providers, err := makeProviders()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to make providers: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user