-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (37 loc) · 755 Bytes
/
Copy pathmain.go
File metadata and controls
53 lines (37 loc) · 755 Bytes
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
// Main
package main
import (
"crypto/rand"
"encoding/hex"
"github.com/joho/godotenv"
)
// Generates an unique ID for the node
func makeId(n int) (string, error) {
bytes := make([]byte, n)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}
const VERSION = "1.0.0"
// Program entry point
func main() {
godotenv.Load() // Load env vars
InitLog()
LogInfo("Started WebRTC CDN - Version " + VERSION)
nodeId, err := makeId(20)
if err != nil {
LogError(err)
}
LogInfo("Assigned node identifier: " + nodeId)
// Create Node service
node := WebRTC_CDN_Node{
id: nodeId,
}
// Init node
node.init()
// Start redis listener
go setupRedisListener(&node)
// Run
node.run()
}