-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
63 lines (55 loc) · 1.3 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
package main
import (
"github.com/sevlyar/go-daemon"
"golang.org/x/net/context"
"log/slog"
)
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
//Setup log system
logSysInit()
//log system ready
//Setup daemon system
cntxt := &daemon.Context{
PidFileName: "gcs.pid",
PidFilePerm: 0644,
LogFileName: GCS_LOG_PATH,
WorkDir: "./",
Umask: 027,
Args: []string{"[gcs]"},
}
if len(daemon.ActiveFlags()) > 0 {
d, err := cntxt.Search()
if err != nil {
slog.Error("cntxt.Search error", "ERR_MSG", err.Error())
}
daemon.SendCommands(d)
return
}
d, err := cntxt.Reborn()
if err != nil {
slog.Error("cntxt.Reborn error", "ERR_MSG", err.Error())
}
if d != nil {
return
}
defer cntxt.Release()
slog.Info("- - - - - - -[GCS] started - - - - - - -")
defer func() {
slog.Info("- - - - - - -[GCS] exited- - - - - - -")
}()
//Daemon system ready
slog.Debug("listenResourceHandler start")
go listenResourceHandler()
slog.Debug("******ReloadUpdateInfo Start******")
//UPDATEMAP = make(map[string][]string)
err = reloadUpdateInfo()
if err != nil {
slog.Error("listenHandler reloadUpdateInfo error", "ERR_MSG", err)
}
slog.Debug("******ReloadUpdateInfo Done******")
slog.Debug("listenHandler start")
go listenHandler()
<-ctx.Done()
}