MCPcopy Index your code
hub / github.com/opencloud-eu/opencloud / Server

Function Server

services/thumbnails/pkg/command/server.go:25–109  ·  view source on GitHub ↗

Server is the entrypoint for the server command.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

23
24// Server is the entrypoint for the server command.
25func Server(cfg *config.Config) *cobra.Command {
26 return &cobra.Command{
27 Use: "server",
28 Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
29 PreRunE: func(cmd *cobra.Command, args []string) error {
30 return configlog.ReturnFatal(parser.ParseConfig(cfg))
31 },
32 RunE: func(cmd *cobra.Command, args []string) error {
33 logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
34
35 traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
36 if err != nil {
37 return err
38 }
39 cfg.GrpcClient, err = ogrpc.NewClient(ogrpc.GetClientOptions(cfg.GRPCClientTLS)...)
40 if err != nil {
41 return err
42 }
43
44 var cancel context.CancelFunc
45 if cfg.Context == nil {
46 cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
47 defer cancel()
48 }
49 ctx := cfg.Context
50
51 m := metrics.New()
52 m.BuildInfo.WithLabelValues(version.GetString()).Set(1)
53
54 gr := runner.NewGroup()
55
56 service := grpc.NewService(
57 grpc.Logger(logger),
58 grpc.Context(ctx),
59 grpc.Config(cfg),
60 grpc.Name(cfg.Service.Name),
61 grpc.Namespace(cfg.GRPC.Namespace),
62 grpc.Address(cfg.GRPC.Addr),
63 grpc.Metrics(m),
64 grpc.TraceProvider(traceProvider),
65 grpc.MaxConcurrentRequests(cfg.GRPC.MaxConcurrentRequests),
66 )
67 gr.Add(runner.NewGoMicroGrpcServerRunner(cfg.Service.Name+".grpc", service))
68
69 server, err := debug.Server(
70 debug.Logger(logger),
71 debug.Config(cfg),
72 debug.Context(ctx),
73 )
74 if err != nil {
75 logger.Info().Err(err).Str("transport", "debug").Msg("Failed to initialize server")
76 return err
77 }
78 gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", server))
79
80 httpServer, err := http.Server(
81 http.Logger(logger),
82 http.Context(ctx),

Callers 1

GetCommandsFunction · 0.70

Calls 15

ReturnFatalFunction · 0.92
ParseConfigFunction · 0.92
ConfigureFunction · 0.92
GetTraceProviderFunction · 0.92
NewFunction · 0.92
GetStringFunction · 0.92
NewGroupFunction · 0.92
NewServiceFunction · 0.92
LoggerFunction · 0.92
ContextFunction · 0.92
ConfigFunction · 0.92
NameFunction · 0.92

Tested by

no test coverage detected