-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (26 loc) · 864 Bytes
/
main.go
File metadata and controls
35 lines (26 loc) · 864 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
// Copyright (c) 2024 Seoyoung Cho and Carlos Andres Cotera Jurado.
package main
import (
"os"
"os/signal"
"syscall"
internalDatabase "github.com/matcha-devs/matcha/internal/database"
internalServer "github.com/matcha-devs/matcha/internal/server"
)
var matcha *app
func init() {
matcha = newApp(
internalServer.New(loggedRouter()), internalDatabase.New("matcha_db", "root", os.Getenv("MYSQL_PASSWORD")),
)
}
func main() {
// Channel to catch "ctrl+c" such that dependencies will be closed safely before opening them.
ctrlC := make(chan os.Signal, 1)
signal.Notify(ctrlC, syscall.SIGINT, syscall.SIGTERM)
// Open said dependencies and run application on a new go routine.
go matcha.run()
// Block the main goroutine until ctrl+c interrupt is raised.
<-ctrlC
// Stop application and close the dependencies before exiting.
matcha.close()
}