Files
kubeshark/api/pkg/utils/utils.go
gadotroee 0061f7d14a Add api build and clean to makefile (files restructure) (#9)
* no message
* add clean api command
2021-04-28 08:08:58 +03:00

38 lines
645 B
Go

package utils
import (
"fmt"
"github.com/gofiber/fiber/v2"
"log"
"os"
"os/signal"
"syscall"
)
// StartServer starts the server with a graceful shutdown
func StartServer(app *fiber.App) {
signals := make(chan os.Signal, 2)
signal.Notify(signals,
os.Interrupt, // this catch ctrl + c
syscall.SIGTSTP, // this catch ctrl + z
)
go func() {
_ = <-signals
fmt.Println("Shutting down...")
_ = app.Shutdown()
}()
// Run server.
if err := app.Listen(":8899"); err != nil {
log.Printf("Oops... Server is not running! Reason: %v", err)
}
}
func CheckErr(e error) {
if e != nil {
log.Printf("%v", e)
//panic(e)
}
}