forked from god-jason/iot-master
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
81 lines (67 loc) · 1.69 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package main
import (
"github.com/god-jason/bucket/api"
"github.com/god-jason/bucket/boot"
_ "github.com/god-jason/bucket/function"
"github.com/god-jason/bucket/pkg/service"
_ "github.com/god-jason/bucket/table"
"github.com/god-jason/bucket/web"
_ "github.com/zgwit/iot-master/v5/action"
_ "github.com/zgwit/iot-master/v5/aggregate"
"github.com/zgwit/iot-master/v5/args"
_ "github.com/zgwit/iot-master/v5/device"
_ "github.com/zgwit/iot-master/v5/gateway"
_ "github.com/zgwit/iot-master/v5/history"
_ "github.com/zgwit/iot-master/v5/product"
_ "github.com/zgwit/iot-master/v5/scene"
_ "github.com/zgwit/iot-master/v5/timer"
_ "github.com/zgwit/iot-master/v5/user"
_ "github.com/zgwit/iot-master/v5/validator"
"log"
)
func main() {
args.Parse()
err := service.Register(Startup, Shutdown)
if err != nil {
log.Fatal(err)
}
if args.Install {
err = service.Install()
if err != nil {
log.Fatal(err)
}
return
}
if args.Uninstall {
err = service.Uninstall()
if err != nil {
log.Fatal(err)
}
return
}
err = service.Run()
if err != nil {
log.Fatal(err)
}
}
func Startup() error {
err := boot.Startup()
if err != nil {
return err
}
//注册前端接口
api.RegisterRoutes(web.Engine.Group("/api"))
//监听Websocket
//web.Engine.GET("/mqtt", broker.GinBridge)
//附件
//web.Engine.Static("/static", "static")
//web.Engine.Static("/attach", filepath.Join(viper.GetString("data"), "attach"))
//前端 移入子工程 github.com/iot-master-contrib/webui
//web.Static.Put("", http.FS(wwwFiles), "www", "index.html")
//注册静态文件
web.Static.PutDir("", "www", "", "index.html")
return web.Serve()
}
func Shutdown() error {
return boot.Shutdown()
}