2019-12-05 09:36:58 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-12-08 03:59:58 -05:00
|
|
|
"time"
|
2019-12-05 09:36:58 -05:00
|
|
|
|
2019-12-08 03:59:58 -05:00
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
|
|
|
"github.com/patrickmn/go-cache"
|
2019-12-05 10:42:20 -05:00
|
|
|
|
2019-12-08 03:59:58 -05:00
|
|
|
"github.com/p14yground/nezha/cmd/dashboard/controller"
|
|
|
|
"github.com/p14yground/nezha/cmd/dashboard/rpc"
|
|
|
|
"github.com/p14yground/nezha/model"
|
|
|
|
"github.com/p14yground/nezha/service/dao"
|
2019-12-05 09:36:58 -05:00
|
|
|
)
|
|
|
|
|
2019-12-08 03:59:58 -05:00
|
|
|
func init() {
|
|
|
|
var err error
|
|
|
|
dao.Conf, err = model.ReadInConfig("data/config.yaml")
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
dao.Admin = &model.User{
|
|
|
|
Login: dao.Conf.GitHub.Admin,
|
|
|
|
}
|
|
|
|
dao.DB, err = gorm.Open("sqlite3", "data/sqlite.db")
|
2019-12-05 09:36:58 -05:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2019-12-08 03:59:58 -05:00
|
|
|
dao.Cache = cache.New(5*time.Minute, 10*time.Minute)
|
|
|
|
}
|
2019-12-05 09:36:58 -05:00
|
|
|
|
2019-12-08 03:59:58 -05:00
|
|
|
func main() {
|
|
|
|
go controller.ServeWeb()
|
|
|
|
go rpc.ServeRPC()
|
|
|
|
select {}
|
2019-12-05 09:36:58 -05:00
|
|
|
}
|