-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (29 loc) · 817 Bytes
/
main.go
File metadata and controls
36 lines (29 loc) · 817 Bytes
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
package main
import (
"context"
"docker-auto-cleaner/docker"
"os"
"time"
"log/slog"
"github.com/docker/go-units"
)
func main() {
if os.Getenv("DEBUG") == "true" {
slog.SetLogLoggerLevel(slog.LevelDebug)
}
threshold, err := units.FromHumanSize(os.Getenv("THRESHOLD"))
if err != nil {
slog.With("error", err).Error("Failed to parse threshold")
threshold = 10 * units.GiB
slog.Warn("Setting threshold to default value", "threshold", threshold)
}
interval, err := time.ParseDuration(os.Getenv("INTERVAL"))
if err != nil {
slog.With("error", err).Error("Failed to parse interval")
interval = 1 * time.Hour
slog.Warn("Setting interval to default value", "interval", interval)
}
ctx := context.Background()
monitor := docker.NewDockerMonitor(ctx, threshold, interval)
monitor.Start()
}