forked from E-cercise/E-cercise-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
40 lines (31 loc) · 780 Bytes
/
main.go
File metadata and controls
40 lines (31 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"github.com/E-cercise/E-cercise/src/config"
"github.com/E-cercise/E-cercise/src/logger"
"github.com/E-cercise/E-cercise/src/router"
"log"
"os"
"os/signal"
)
func main() {
config.Init()
logger.Init()
db := config.DatabaseConnection()
app := router.InitRouter(db)
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
// Run the app in a goroutine
go func() {
if err := app.Listen(":8888"); err != nil {
log.Fatalf("Error starting server: %v", err)
}
}()
// Wait for interrupt signal
<-quit
log.Println("Gracefully shutting down server...")
// Gracefully shutdown Fiber
if err := app.Shutdown(); err != nil {
log.Fatalf("Error during server shutdown: %v", err)
}
log.Println("Server successfully stopped")
}