mirror of
https://github.com/IceWhaleTech/CasaOS.git
synced 2025-12-22 20:44:42 +00:00
Socketio modification (#771)
This commit is contained in:
12
main.go
12
main.go
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/IceWhaleTech/CasaOS-Common/model"
|
||||
"github.com/IceWhaleTech/CasaOS-Common/utils/constants"
|
||||
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
|
||||
"github.com/IceWhaleTech/CasaOS/model/notify"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/cache"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/config"
|
||||
"github.com/IceWhaleTech/CasaOS/pkg/sqlite"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
"github.com/IceWhaleTech/CasaOS/service"
|
||||
"github.com/IceWhaleTech/CasaOS/types"
|
||||
"github.com/coreos/go-systemd/daemon"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/robfig/cron"
|
||||
@@ -53,7 +53,7 @@ func init() {
|
||||
sqliteDB = sqlite.GetDb(*dbFlag)
|
||||
// gredis.GetRedisConn(config.RedisInfo),
|
||||
|
||||
service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath)
|
||||
service.MyService = service.NewService(sqliteDB, config.CommonInfo.RuntimePath, route.SocketIo())
|
||||
|
||||
service.Cache = cache.Init()
|
||||
|
||||
@@ -74,15 +74,17 @@ func init() {
|
||||
// @name Authorization
|
||||
// @BasePath /v1
|
||||
func main() {
|
||||
service.NotifyMsg = make(chan notify.Message, 10)
|
||||
if *versionFlag {
|
||||
return
|
||||
}
|
||||
go route.SocketInit(service.NotifyMsg)
|
||||
// model.Setup()
|
||||
// gredis.Setup()
|
||||
|
||||
r := route.InitRouter()
|
||||
defer service.SocketServer.Close()
|
||||
r.GET("/v1/socketio/*any", gin.WrapH(service.SocketServer))
|
||||
r.POST("/v1/socketio/*any", gin.WrapH(service.SocketServer))
|
||||
|
||||
// service.SyncTask(sqliteDB)
|
||||
cron2 := cron.New()
|
||||
// every day execution
|
||||
@@ -108,7 +110,7 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
routers := []string{"sys", "port", "file", "folder", "batch", "image", "samba", "notify"}
|
||||
routers := []string{"sys", "port", "file", "folder", "batch", "image", "samba", "notify", "socketio"}
|
||||
for _, v := range routers {
|
||||
err = service.MyService.Gateway().CreateRoute(&model.Route{
|
||||
Path: "/v1/" + v,
|
||||
|
||||
Reference in New Issue
Block a user