logging fixes
parent
4e4c17a41a
commit
5ae73b9bb7
12
blockbook.go
12
blockbook.go
|
@ -146,17 +146,17 @@ func waitForSignalAndShutdown(s *server.HttpServer, timeout time.Duration) {
|
|||
|
||||
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
<-stop
|
||||
sig := <-stop
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
log.Printf("\nShutdown with timeout: %s\n", timeout)
|
||||
log.Printf("Shutdown %v", sig)
|
||||
|
||||
if err := s.Shutdown(ctx); err != nil {
|
||||
log.Printf("Error: %v\n", err)
|
||||
} else {
|
||||
log.Println("Server stopped")
|
||||
if s != nil {
|
||||
if err := s.Shutdown(ctx); err != nil {
|
||||
log.Printf("Error: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"blockbook/db"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -38,17 +38,17 @@ func New(db *db.RocksDB) (*HttpServer, error) {
|
|||
}
|
||||
|
||||
func (s *HttpServer) Run() error {
|
||||
fmt.Printf("http server starting on port %s", s.https.Addr)
|
||||
log.Printf("http server starting on port %s", s.https.Addr)
|
||||
return s.https.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *HttpServer) Close() error {
|
||||
fmt.Printf("http server closing")
|
||||
log.Printf("http server closing")
|
||||
return s.https.Close()
|
||||
}
|
||||
|
||||
func (s *HttpServer) Shutdown(ctx context.Context) error {
|
||||
fmt.Printf("http server shutdown")
|
||||
log.Printf("http server shutdown")
|
||||
return s.https.Shutdown(ctx)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue