-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (42 loc) · 1.05 KB
/
main.go
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
49
50
51
52
53
54
package main
import (
"database/sql"
"fmt"
"log"
"os"
"os/signal"
"syscall"
migrate "github.com/rubenv/sql-migrate"
"github.com/arabian9ts/sweeTest/app/builder"
"github.com/arabian9ts/sweeTest/config"
"github.com/arabian9ts/sweeTest/infrastructure"
)
var (
version string
)
func main() {
migrations := &migrate.FileMigrationSource{
Dir: "db/migrations",
}
db, err := sql.Open("mysql", config.GetRdbUri())
if err != nil {
fmt.Println("failed to connect mysql")
}
n, err := migrate.Exec(db, "mysql", migrations, migrate.Up)
if err != nil {
fmt.Println("failed to migrate")
}
fmt.Printf("Applied %d migrations!\n", n)
controllers, err := builder.InitializeRootController()
if err != nil {
panic("failed to initialize controllers")
}
handlers, err := builder.InitializeRootHandler()
if err != nil {
panic("failed to initialize auth handler")
}
infrastructure.Router(controllers, handlers, version).Run()
q := make(chan os.Signal, 1)
signal.Notify(q, syscall.SIGTERM, os.Interrupt)
log.Println("shutting down SIGNAL:", <-q)
}