-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
49 lines (35 loc) · 1.24 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
package main
import (
_ "embed"
"os"
"github.com/docker/go-plugins-helpers/volume"
"github.com/op/go-logging"
)
func initLogger() *logging.Logger {
// Define the log format
logFormat := logging.MustStringFormatter(
"%{color:reset}%{color}%{time:2006-01-02 15:04:05.000} ▶ %{level:.4s} %{message} [in %{shortfunc}]",
)
// Create a log backend that writes to standard error
backend := logging.NewLogBackend(os.Stderr, "", 0)
// Apply the log format to the backend
backendFormatter := logging.NewBackendFormatter(backend, logFormat)
// Set the backend as the logging backend
logging.SetBackend(backendFormatter)
// Enable Debug level logs
logging.SetLevel(logging.DEBUG, "")
// Create and return the logger
return logging.MustGetLogger("docker-on-top")
}
var log *logging.Logger = initLogger()
//go:embed docker-on-top_version.txt
var Version []byte
func main() {
log.Infof("Starting docker-on-top v%s", string(Version))
dotRootDir := "/var/lib/docker-on-top/"
socketPath := "/run/docker/plugins/docker-on-top.sock"
handler := volume.NewHandler(MustNewDockerOnTop(dotRootDir))
log.Infof("Serving at %s", socketPath)
log.Critical(handler.ServeUnix(socketPath, 0))
// TODO: in case of abrupt termination, delete the socket file
}