-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (36 loc) · 792 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
44
package main
import (
"context"
"fmt"
"log"
"os"
"os/signal"
"time"
"github.com/carlmjohnson/versioninfo"
"github.com/urfave/cli/v2"
"github.com/grishy/go-avahi-cname/cmd"
)
func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, os.Kill)
defer stop()
// Add a handler for force exiting if we don't exit gracefully (stuck)
go func() {
<-ctx.Done()
time.Sleep(3 * time.Second)
log.Print("Force exit")
os.Exit(1)
}()
app := &cli.App{
Name: "go-avahi-cname",
Usage: "A tool for publishing CNAME records with Avahi",
Version: versioninfo.Short(),
Commands: []*cli.Command{
cmd.Cname(ctx),
cmd.Subdomain(ctx),
},
}
if err := app.Run(os.Args); err != nil {
fmt.Println("Error:")
fmt.Printf(" > %+v\n", err)
}
}