Skip to content

Commit

Permalink
fix DB
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Jul 12, 2024
1 parent 1db8616 commit a7c8156
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,12 @@ func main() {
info := Info{
Version: version,
}
if err := r.DB().QueryRow("select count(*) from event").Scan(&info.NumEvents); err != nil {
log.Println(err)
if db := r.DB(); db != nil {
if err := db.QueryRow("select count(*) from event").Scan(&info.NumEvents); err != nil {
log.Println(err)
}
info.NumSessions = int64(r.DB().Stats().OpenConnections)
}
info.NumSessions = int64(r.DB().Stats().OpenConnections)
json.NewEncoder(w).Encode(info)
})
server.Router().HandleFunc("/reload", func(w http.ResponseWriter, req *http.Request) {
Expand Down

0 comments on commit a7c8156

Please sign in to comment.