-
Notifications
You must be signed in to change notification settings - Fork 34
/
main.go
35 lines (29 loc) · 677 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
// Runs a container reaper that listens for connections and prunes resources based on the filters received.
package main
import (
"context"
"fmt"
"log/slog"
"os"
"os/signal"
"syscall"
)
// run creates and runs a reaper which is cancelled when a signal is received.
func run() error {
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
r, err := newReaper(ctx)
if err != nil {
return fmt.Errorf("new reaper: %w", err)
}
if err = r.run(ctx); err != nil {
return fmt.Errorf("run: %w", err)
}
return nil
}
func main() {
if err := run(); err != nil {
slog.Error("run", fieldError, err)
os.Exit(1)
}
}