-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
61 lines (49 loc) · 1.28 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
// Copyright © 2021-2023 The Gomon Project.
package main
import (
"context"
"os"
"strconv"
"strings"
"github.com/zosmac/gocore"
"github.com/zosmac/gomon/file"
"github.com/zosmac/gomon/logs"
"github.com/zosmac/gomon/message"
"github.com/zosmac/gomon/process"
"github.com/zosmac/gomon/serve"
)
// main
func main() {
gocore.Main(Main)
}
// Main called from gocore.Main.
func Main(ctx context.Context) error {
if gocore.Flags.FlagSet.Lookup("document").Value.String() == "true" {
message.Document()
return nil
}
if err := message.Encoder(ctx); err != nil {
return gocore.Error("encoder", err)
}
if err := logs.Observer(ctx); err != nil {
return gocore.Error("logs Observer", err)
}
if err := file.Observer(ctx); err != nil {
return gocore.Error("files Observer", err)
}
if err := process.Observer(ctx); err != nil {
return gocore.Error("processes Observer", err)
}
// fire up the http server
serve.Serve(ctx)
gocore.Error("start", nil, map[string]string{
"pid": strconv.Itoa(os.Getpid()),
"command": strings.Join(os.Args, " "),
"executable": gocore.Executable,
"version": gocore.Version,
"user": gocore.Username(os.Getuid()),
}).Info()
return gocore.Error("stop", serve.Measure(ctx), map[string]string{
"command": os.Args[0],
})
}