mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-10-01 15:45:26 +00:00
* no message * infinite scroll + new ws implementation * no message * scrolling top * fetch button * more Backend changes * fix go mod and sum * mire fixes against develop * unused code * small ui refactor Co-authored-by: Roee Gadot <roee.gadot@up9.com>
50 lines
975 B
Go
50 lines
975 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gofiber/fiber/v2"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"reflect"
|
|
"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 ReverseSlice(data interface{}) {
|
|
value := reflect.ValueOf(data)
|
|
valueLen := value.Len()
|
|
for i := 0; i <= int((valueLen-1)/2); i++ {
|
|
reverseIndex := valueLen - 1 - i
|
|
tmp := value.Index(reverseIndex).Interface()
|
|
value.Index(reverseIndex).Set(value.Index(i))
|
|
value.Index(i).Set(reflect.ValueOf(tmp))
|
|
}
|
|
}
|
|
|
|
|
|
func CheckErr(e error) {
|
|
if e != nil {
|
|
log.Printf("%v", e)
|
|
//panic(e)
|
|
}
|
|
} |