-
Notifications
You must be signed in to change notification settings - Fork 0
/
picoinit.go
47 lines (39 loc) · 941 Bytes
/
picoinit.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
// Command picoinit is a combo minimalistic init and service manager process
// to launch and manage multiple services within a single docker container.
package main
import (
"os"
"github.com/tuxdude/pico"
"github.com/tuxdude/zzzlog"
"github.com/tuxdude/zzzlogi"
)
var (
log = buildLogger()
)
func buildLogger() zzzlogi.Logger {
config := zzzlog.NewConsoleLoggerConfig()
config.MaxLevel = zzzlog.LvlWarn
return zzzlog.NewLogger(config)
}
func run() int {
inv, err := parseFlags()
if err != nil {
log.Fatal(err)
}
log.Infof("Invocation: %v", inv)
init, err := pico.NewInit(&pico.InitConfig{
Log: log,
PreHook: inv.preHook,
Services: inv.services,
})
if err != nil {
log.Errorf("picoinit failed to initialize and launch the services, reason: %v", err)
return 1
}
exitCode := init.Wait()
log.Infof("picoinit exiting with status code: %d", exitCode)
return exitCode
}
func main() {
os.Exit(run())
}