This repository was archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.go
77 lines (65 loc) · 1.37 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
package main
import (
"embed"
//_ "git.zgwit.com/gateway/dlt645"
"github.com/god-jason/bucket/boot"
"github.com/god-jason/bucket/pkg/service"
"github.com/god-jason/bucket/web"
_ "github.com/zgwit/iot-gateway/admin"
"github.com/zgwit/iot-gateway/api"
"github.com/zgwit/iot-gateway/args"
_ "github.com/zgwit/iot-gateway/client"
_ "github.com/zgwit/iot-gateway/device"
_ "github.com/zgwit/iot-gateway/modbus"
_ "github.com/zgwit/iot-gateway/product"
_ "github.com/zgwit/iot-gateway/serial"
_ "github.com/zgwit/iot-gateway/server"
"log"
"net/http"
)
// go: embed all:www
var wwwFiles embed.FS
func main() {
args.Parse()
err := service.Register(Startup, Shutdown)
if err != nil {
log.Fatal(err)
}
if args.Uninstall {
err = service.Uninstall()
if err != nil {
log.Fatal(err)
}
log.Println("卸载服务成功")
return
}
if args.Install {
err = service.Install()
if err != nil {
log.Fatal(err)
}
log.Println("安装服务成功")
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"))
//阻塞
return web.Serve()
}
func Static(fs *web.FileSystem) {
//前端静态文件
fs.Put("", http.FS(wwwFiles), "www", "www/index.html")
}
func Shutdown() error {
return boot.Shutdown()
}