Added sigHandler to print stackTrace, modified probe params

This commit is contained in:
smruthi2187
2018-02-08 13:58:44 -08:00
parent 93dde93afe
commit bce45d6d25
8 changed files with 102 additions and 17 deletions
+16
View File
@@ -24,6 +24,9 @@ import (
"os"
"strconv"
"time"
"os/signal"
"syscall"
"runtime/debug"
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
@@ -171,7 +174,20 @@ func (ss *StorageService) Start(port int) {
log.Fatal(http.ListenAndServe(address, handlers.LoggingHandler(os.Stdout, r)))
}
func dumpStackTrace() {
debug.PrintStack()
}
func RunStorageService(storageType StorageType, storagePath string, containerName string, port int, enablePruner bool) *StorageService {
// register signal handler for dumping stack trace.
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
dumpStackTrace()
os.Exit(1)
}()
// initialize logger
log.SetLevel(log.InfoLevel)