mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-06 21:11:11 +00:00
TRA-3437 switch fiber and ikisocket with gin-gonic and gorilla websocket (#136)
* WIP * WIP * WIP * Update socket_server_handlers.go and socket_routes.go * Fix stuck sockets * Update go.mod, go.sum, and 5 more files... * Update socket_routes.go * Update Dockerfile, go.sum, and fiber_middleware.go * fix analyze Co-authored-by: RamiBerm <rami.berman@up9.com>
This commit is contained in:
@@ -1,32 +1,42 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"context"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/romana/rlog"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"reflect"
|
||||
"syscall"
|
||||
"time"
|
||||
)
|
||||
|
||||
// StartServer starts the server with a graceful shutdown
|
||||
func StartServer(app *fiber.App) {
|
||||
func StartServer(app *gin.Engine) {
|
||||
signals := make(chan os.Signal, 2)
|
||||
signal.Notify(signals,
|
||||
os.Interrupt, // this catch ctrl + c
|
||||
syscall.SIGTSTP, // this catch ctrl + z
|
||||
)
|
||||
|
||||
srv := &http.Server{
|
||||
Addr: ":8080",
|
||||
Handler: app,
|
||||
}
|
||||
|
||||
go func() {
|
||||
_ = <-signals
|
||||
rlog.Infof("Shutting down...")
|
||||
_ = app.Shutdown()
|
||||
ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
_ = srv.Shutdown(ctx)
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
// Run server.
|
||||
if err := app.Listen(":8899"); err != nil {
|
||||
if err := app.Run(":8899"); err != nil {
|
||||
log.Printf("Oops... Server is not running! Reason: %v", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user