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

Function Server

services/webdav/pkg/command/server.go:23–102  ·  view source on GitHub ↗

Server is the entrypoint for the server command.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

21
22// Server is the entrypoint for the server command.
23func Server(cfg *config.Config) *cobra.Command {
24 return &cobra.Command{
25 Use: "server",
26 Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
27 PreRunE: func(cmd *cobra.Command, args []string) error {
28 return configlog.ReturnFatal(parser.ParseConfig(cfg))
29 },
30 RunE: func(cmd *cobra.Command, args []string) error {
31 logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
32 traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
33 if err != nil {
34 return err
35 }
36 cfg.GrpcClient, err = ogrpc.NewClient(
37 append(ogrpc.GetClientOptions(cfg.GRPCClientTLS),
38 ogrpc.WithTraceProvider(traceProvider),
39 )...)
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 metrics := metrics.New()
52 metrics.BuildInfo.WithLabelValues(version.GetString()).Set(1)
53
54 gr := runner.NewGroup()
55 {
56 server, err := http.Server(
57 http.Logger(logger),
58 http.Context(ctx),
59 http.Config(cfg),
60 http.Metrics(metrics),
61 http.TraceProvider(traceProvider),
62 )
63
64 if err != nil {
65 logger.Info().
66 Err(err).
67 Str("server", "http").
68 Msg("Failed to initialize server")
69
70 return err
71 }
72
73 gr.Add(runner.NewGoMicroHttpServerRunner(cfg.Service.Name+".http", server))
74 }
75
76 {
77 debugServer, err := debug.Server(
78 debug.Logger(logger),
79 debug.Context(ctx),
80 debug.Config(cfg),

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
ServerFunction · 0.92
LoggerFunction · 0.92
ContextFunction · 0.92
ConfigFunction · 0.92
MetricsFunction · 0.92

Tested by

no test coverage detected