MCPcopy Create free account
hub / github.com/opencloud-eu/opencloud / Server

Function Server

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

Server is the entry point for the server command.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

23
24// Server is the entry point 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 traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
35 if err != nil {
36 return err
37 }
38
39 var cancel context.CancelFunc
40 if cfg.Context == nil {
41 cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
42 defer cancel()
43 }
44 ctx := cfg.Context
45
46 gr := runner.NewGroup()
47
48 // the reva runtime calls `os.Exit` in the case of a failure and there is no way for the OpenCloud
49 // runtime to catch it and restart a reva service. Therefore, we need to ensure the service has
50 // everything it needs, before starting the service.
51 // In this case: CA certificates
52 if cfg.AuthProvider == "ldap" {
53 ldapCfg := cfg.AuthProviders.LDAP
54 if err := ldap.WaitForCA(logger, ldapCfg.Insecure, ldapCfg.CACert); err != nil {
55 logger.Error().Err(err).Msg("The configured LDAP CA cert does not exist")
56 return err
57 }
58 }
59
60 {
61 // run the appropriate reva servers based on the config
62 rCfg := revaconfig.AuthBasicConfigFromStruct(cfg)
63 if rServer := runtime.NewDrivenHTTPServerWithOptions(rCfg,
64 runtime.WithLogger(&logger.Logger),
65 runtime.WithRegistry(registry.GetRegistry()),
66 runtime.WithTraceProvider(traceProvider),
67 ); rServer != nil {
68 gr.Add(runner.NewRevaServiceRunner(cfg.Service.Name+".rhttp", rServer))
69 }
70 if rServer := runtime.NewDrivenGRPCServerWithOptions(rCfg,
71 runtime.WithLogger(&logger.Logger),
72 runtime.WithRegistry(registry.GetRegistry()),
73 runtime.WithTraceProvider(traceProvider),
74 ); rServer != nil {
75 gr.Add(runner.NewRevaServiceRunner(cfg.Service.Name+".rgrpc", rServer))
76 }
77 }
78
79 {
80 debugServer, err := debug.Server(
81 debug.Logger(logger),
82 debug.Context(ctx),

Callers 1

GetCommandsFunction · 0.70

Calls 15

ReturnFatalFunction · 0.92
ParseConfigFunction · 0.92
ConfigureFunction · 0.92
GetTraceProviderFunction · 0.92
NewGroupFunction · 0.92
WaitForCAFunction · 0.92
GetRegistryFunction · 0.92
NewRevaServiceRunnerFunction · 0.92
ServerFunction · 0.92
LoggerFunction · 0.92
ContextFunction · 0.92

Tested by

no test coverage detected