Remove graceful shutdown
This commit is contained in:
13
src/main.go
13
src/main.go
@@ -2,12 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
@@ -95,11 +94,9 @@ func main() {
|
|||||||
|
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
go ListenAndServe(conf.Host, conf.Port+instanceID)
|
log.Printf("Listening on %s:%d\n", conf.Host, conf.Port+instanceID)
|
||||||
|
|
||||||
defer app.Shutdown()
|
if err := app.Listen(fmt.Sprintf("%s:%d", conf.Host, conf.Port+instanceID)); err != nil {
|
||||||
|
panic(err)
|
||||||
s := make(chan os.Signal, 1)
|
}
|
||||||
signal.Notify(s, os.Interrupt, syscall.SIGTERM)
|
|
||||||
<-s
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ListenAndServe(host string, port uint16) {
|
func ListenAndServe(host string, port uint16) {
|
||||||
log.Printf("Listening on %s:%d\n", host, port)
|
|
||||||
|
|
||||||
if err := app.Listen(fmt.Sprintf("%s:%d", host, port)); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user