-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 929 Bytes
/
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
package main
import (
"time"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"github.com/patrickmn/go-cache"
"github.com/robfig/cron/v3"
"github.com/naiba/poorsquad/controller"
"github.com/naiba/poorsquad/model"
"github.com/naiba/poorsquad/service/dao"
"github.com/naiba/poorsquad/service/github"
)
func main() {
cf, err := model.ReadInConfig("data/config.yaml")
if err != nil {
panic(err)
}
db, err := gorm.Open("sqlite3", "data/github.db")
if err != nil {
panic(err)
}
if cf.Debug {
db = db.Debug()
}
db.AutoMigrate(model.User{}, model.Company{}, model.UserCompany{},
model.Account{}, model.Team{}, model.Repository{}, model.UserRepository{},
model.UserTeam{}, model.TeamRepository{})
dao.Init(db, cache.New(5*time.Minute, 10*time.Minute), cf)
go controller.RunWeb()
go github.SyncAll()
c := cron.New()
c.AddFunc("@every 2h", github.SyncAll)
c.Start()
select {}
}