-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshkaff.go
executable file
·61 lines (55 loc) · 1.08 KB
/
shkaff.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
package main
import (
"log"
"os"
"shkaff/apps/api"
"shkaff/apps/operator"
"shkaff/apps/statsender"
"shkaff/apps/worker"
"shkaff/internal/fork"
"shkaff/internal/options"
)
type Creater interface {
Init(action string, cfg options.ShkaffConfig) *Service
}
type Service interface {
Run()
Stop()
}
type shkaff struct{}
func (self *shkaff) Init(action string) (srv Service) {
switch action {
case "Operator":
srv = operator.InitOperator()
case "Worker":
srv = worker.InitWorker()
case "StatWorker":
srv = statsender.InitStatSender()
case "API":
srv = api.InitAPI()
default:
log.Fatalf("Unknown Shkaff service name %s\n", action)
}
return
}
func startShkaff() {
servicesName := []string{"Operator", "Worker", "StatWorker", "API"}
shkf := new(shkaff)
for _, name := range servicesName {
s := shkf.Init(name)
go s.Run()
}
}
func main() {
daemon, err := fork.InitDaemon()
if err != nil {
log.Println("Error: ", err)
os.Exit(1)
}
status, err := daemon.Run(startShkaff)
if err != nil {
log.Println(status, "\nError+++: ", err)
os.Exit(3)
}
log.Println(status)
}