-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (37 loc) · 901 Bytes
/
main.go
File metadata and controls
48 lines (37 loc) · 901 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
41
42
43
44
45
46
47
48
package main
import (
"context"
"log"
"time"
"swiftschool/config"
"swiftschool/helper"
"swiftschool/server"
"github.com/joho/godotenv"
_ "github.com/lib/pq"
)
// Initialize logger
func init() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
}
func main() {
logger := helper.GetLogger()
// Load .env file from root directory
if err := godotenv.Load(); err != nil {
logger.Error("error loading .env file: %v", err)
}
// Create context with cancellation
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
// Load configurations
cfg, err := config.New(ctx)
if err != nil {
logger.Error("Failed to load configuration: ", err)
}
// Create and start the server
srv := server.NewServer(cfg)
// Start the server
logger.Info("Server starting...")
if err := srv.Start(); err != nil {
logger.Error("Server failed to start: ", err)
}
}