Reputation: 59
My Go gRPC Server stops without I stop it by myself. Right now I need to start the server again by entering the command "go run server.go" whenever I see it not responding every 30 or 60 minutes.
Is this normal? Do I need to restart the server after specific amount of time?
Upvotes: 0
Views: 2524
Reputation: 914
import "runtime/debug"
defer func() {
if err := recover(); err != nil {
log.Errorf("Recovered from err: %v\n %s", err, debug.Stack())
}
}()
import (
panichandler "github.com/kazegusuri/grpc-panic-handler"
)
func main() {
uIntOpt := grpc.UnaryInterceptor(panichandler.UnaryPanicHandler)
sIntOpt := grpc.StreamInterceptor(panichandler.StreamPanicHandler)
grpc.NewServer(uIntOpt, sIntOpt)
}
The second approach is more reliable when recovery handler approach is faster to add
Upvotes: 2
Reputation: 79
Try these options 1. Check your logs of what happens before it exits(Dump the logs to a file to verify the issue) 2. Did you add any external package to the codebase which caused this?
Upvotes: 0
Reputation: 83
I'm studying golang recently, I found go lang error handling different. If you want it will not force you to use err, and bad part is it will not show you anything. So please check your programs have any error or not. And also for experts help you need to be more clear about question. Show some code or indication than people can observe where is the problem. Just saying my program crashed will help you by anything.
Upvotes: 0