-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
43 lines (36 loc) · 936 Bytes
/
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
package main
import (
"os"
"github.com/docker/go-plugins-helpers/sdk"
hblogs "github.com/humpback/gounits/logger"
"github.com/humpback/gounits/system"
"github.com/humpback/humpback-logdriver/conf"
"github.com/humpback/humpback-logdriver/driver"
"github.com/humpback/humpback-logdriver/handlers"
)
func main() {
if err := conf.New("./conf/config.yaml"); err != nil {
panic(err)
}
hblogs.OPEN(conf.LoggerArgs())
hblogs.INFO("[#main#] plugin driver environment is [%s]", conf.Environment())
pluginDriver, err := driver.New()
if err != nil {
panic(err)
}
defer func() {
pluginDriver.Close()
hblogs.INFO("[#main#] plugin driver exited.")
hblogs.CLOSE()
os.Exit(0)
}()
go func() {
handler := sdk.NewHandler(`{"Implements": ["LoggingDriver"]}`)
handlers.Routes(&handler, pluginDriver)
err := handler.ServeUnix("humpbacklogdriver", 0)
if err != nil {
panic(err)
}
}()
system.InitSignal(nil)
}