-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
55 lines (45 loc) · 869 Bytes
/
server.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
package dyndns
import (
"sync"
"go.uber.org/zap"
)
// Server represents dynamic DNS registration server.
type Server struct {
name string
log *zap.Logger
ctx *Context
cfg *Config
}
// NewServer return an instance of Server.
func NewServer() *Server {
s := &Server{
name: "dyndns",
}
s.initLogger()
s.initConfig()
s.initContext()
return s
}
// Run is starts the Server.
func (s *Server) Run() error {
var wg sync.WaitGroup
var sybsystemCount int
go runSignalManager(s)
// Configuration Management
wg.Add(1)
sybsystemCount++
go runConfigManager(s, &wg)
// Dynamic DNS Registration
wg.Add(1)
sybsystemCount++
go runRegistrationManager(s, &wg)
// Service Management
wg.Add(1)
go runServiceManager(s, &wg, sybsystemCount)
s.log.Info(
"started all subsystems",
zap.String("app", s.name),
)
wg.Wait()
return s.ctx.fatalError
}