golang 运行进程奔溃 又没报错信息 有什么软件可以检测嘛 用nohup启的 nohup.log文件里面没有报错信息
是这样吗
```
import (
"fmt"
"log"
"net/http"
)
func main() {
go func() {
for {
err := recover()
if err != nil {
log.Println("Recovered from error:", err)
}
}
}()
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
log.Println("Recovered from HTTP error:", err)
}
}()
// your HTTP handler code here
})
log.Fatal(http.ListenAndServe(":8080", nil))
}
```
#10
更多评论