mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 05:30:05 +00:00
Web 服务
This commit is contained in:
@@ -1,27 +1,36 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/jinzhu/gorm/dialects/sqlite"
|
||||
"github.com/patrickmn/go-cache"
|
||||
|
||||
pb "github.com/p14yground/nezha/proto"
|
||||
"github.com/p14yground/nezha/service/handler"
|
||||
"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"
|
||||
)
|
||||
|
||||
func main() {
|
||||
server := grpc.NewServer()
|
||||
pb.RegisterNezhaServiceServer(server, &handler.NezhaHandler{
|
||||
Auth: &handler.AuthHandler{
|
||||
AppKey: "naiba",
|
||||
AppSecret: "123456",
|
||||
},
|
||||
})
|
||||
|
||||
lis, err := net.Listen("tcp", ":5555")
|
||||
func init() {
|
||||
var err error
|
||||
dao.Conf, err = model.ReadInConfig("data/config.yaml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
server.Serve(lis)
|
||||
dao.Admin = &model.User{
|
||||
Login: dao.Conf.GitHub.Admin,
|
||||
}
|
||||
dao.DB, err = gorm.Open("sqlite3", "data/sqlite.db")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
dao.Cache = cache.New(5*time.Minute, 10*time.Minute)
|
||||
}
|
||||
|
||||
func main() {
|
||||
go controller.ServeWeb()
|
||||
go rpc.ServeRPC()
|
||||
select {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user