Replace the service bearer tokens with [tls] ca_file and cert_dir. Caller identity comes from the verified certificate, not metadata. Without TLS, services listen and dial on loopback only. Task containers get only the CA and keep their grant.
52 lines
2.1 KiB
Go
52 lines
2.1 KiB
Go
// Command archie-state-store hosts the State Store's gRPC contract and is the
|
|
// only process that owns the PostgreSQL stores behind it.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"os/signal"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"github.com/samcharles93/archie-core/internal/app/statestore"
|
|
"github.com/samcharles93/archie-core/internal/buildinfo"
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/configuration"
|
|
)
|
|
|
|
func main() { os.Exit(run()) }
|
|
|
|
func run() int {
|
|
// A leading non-flag argument selects a recovery subcommand; anything else,
|
|
// including no arguments at all, serves the State Store contract. An
|
|
// unrecognised word is refused rather than ignored, so a mistyped recovery
|
|
// command never leaves an operator watching a server start instead.
|
|
if args := os.Args[1:]; statestore.IsAccessResetArgs(args) {
|
|
return statestore.RunAccessReset(context.Background(), args[2:], os.Stderr)
|
|
}
|
|
if args := os.Args[1:]; len(args) > 0 && !strings.HasPrefix(args[0], "-") {
|
|
return runRecovery(args, os.Stdout, os.Stderr)
|
|
}
|
|
var options statestore.Options
|
|
showVersion := buildinfo.RegisterVersionFlag("archie-state-store")
|
|
flag.StringVar(&options.Config, "config", configuration.DefaultConfigPath(), "configuration file or directory")
|
|
flag.StringVar(&options.Overlay, "config-overlay", "", "configuration overlay file or directory")
|
|
flag.StringVar(&options.Listen, "listen", "", "state store gRPC listen address (defaults to [services.state].listen, else 127.0.0.1:9090)")
|
|
flag.StringVar(&options.ReadyAddr, "ready-addr", "", "optional readiness HTTP listen address (e.g. 127.0.0.1:9091)")
|
|
flag.Usage = func() {
|
|
fmt.Fprintf(flag.CommandLine.Output(), "usage: archie-state-store [flags] # serve the State Store gRPC contract\n\noffline recovery: archie-state-store <backup|restore|validate|rollback> -h | access reset -h\n\n")
|
|
flag.PrintDefaults()
|
|
}
|
|
flag.Parse()
|
|
showVersion()
|
|
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
|
|
defer stop()
|
|
if err := statestore.Run(ctx, options); err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
return 1
|
|
}
|
|
return 0
|
|
}
|