-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
43 lines (34 loc) · 870 Bytes
/
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
package main
import (
"github.com/rod41732/cu-smart-farm-backend/router"
"log"
"net"
"net/http"
"net/rpc"
"time"
"github.com/rod41732/cu-smart-farm-backend/config"
"github.com/rod41732/cu-smart-farm-backend/common"
"github.com/rod41732/cu-smart-farm-backend/mqtt"
"github.com/rod41732/cu-smart-farm-backend/service/receiver"
"github.com/rod41732/cu-smart-farm-backend/service/worker"
)
// Process for worker
func main() {
config.Init()
router.InitMQTT("worker")
go mqtt.MQTT()
common.ShouldPrintDebug = true
trigger := new(receiver.Trigger)
rpc.Register(trigger)
rpc.HandleHTTP()
// common.InitializeKeyPair()
// middleware.Initialize()
time.Sleep(2 * time.Second) // wait until MQTT connect
l, err := net.Listen("tcp", ":5555")
if err != nil {
log.Fatal("listen error: ", err)
}
worker.Init()
go worker.Work()
http.Serve(l, nil)
}