github.com/anycable/anycable-go@v1.5.1/cmd/anycable-go/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"os"
     7  
     8  	"github.com/anycable/anycable-go/cli"
     9  	_ "github.com/anycable/anycable-go/diagnostics"
    10  
    11  	_ "unsafe"
    12  )
    13  
    14  // IgnorePC is responsible for adding callers pointer to log records.
    15  // We don't use `AddSource` in our handler, so why not dropping the `runtime.Callers` overhead?
    16  // See also https://github.com/rs/zerolog/issues/571#issuecomment-1697479194
    17  //
    18  //go:linkname IgnorePC log/slog/internal.IgnorePC
    19  var IgnorePC = true
    20  
    21  func main() {
    22  	c, err, ok := cli.NewConfigFromCLI(os.Args)
    23  	if err != nil {
    24  		log.Fatalf("%v", err)
    25  	}
    26  	if ok {
    27  		os.Exit(0)
    28  	}
    29  
    30  	opts := []cli.Option{
    31  		cli.WithName("AnyCable"),
    32  		cli.WithDefaultRPCController(),
    33  		cli.WithDefaultBroker(),
    34  		cli.WithDefaultSubscriber(),
    35  		cli.WithDefaultBroadcaster(),
    36  		cli.WithTelemetry(),
    37  	}
    38  
    39  	runner, err := cli.NewRunner(c, opts)
    40  
    41  	if err != nil {
    42  		fmt.Printf("%+v\n", err)
    43  		os.Exit(1)
    44  	}
    45  
    46  	err = runner.Run()
    47  
    48  	if err != nil {
    49  		fmt.Printf("%+v\n", err)
    50  		os.Exit(1)
    51  	}
    52  }