initial commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// Command redapricot-client runs the Go client that registers routing patterns
|
||||
// with a redapricot hub and forwards player traffic to real destinations.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/iceBear67/redapricot/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
if len(args) < 1 {
|
||||
log.Fatal("usage: redapricot-client <config.json>")
|
||||
}
|
||||
|
||||
cfg, err := client.LoadConfig(args[0])
|
||||
if err != nil {
|
||||
log.Fatalf("config: %v", err)
|
||||
}
|
||||
|
||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer cancel()
|
||||
|
||||
c := client.New(cfg)
|
||||
if err := c.Start(ctx); err != nil {
|
||||
log.Fatalf("start: %v", err)
|
||||
}
|
||||
log.Printf("redapricot client running; %d mapping(s) registered", len(cfg.Mappings))
|
||||
|
||||
<-ctx.Done()
|
||||
log.Printf("shutting down")
|
||||
c.Close()
|
||||
}
|
||||
Reference in New Issue
Block a user