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

Function Server

services/sharing/pkg/command/server.go:26–114  ·  view source on GitHub ↗

Server is the entry point for the server command.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

24
25// Server is the entry point for the server command.
26func Server(cfg *config.Config) *cobra.Command {
27 return &cobra.Command{
28 Use: "server",
29 Short: fmt.Sprintf("start the %s service without runtime (unsupervised mode)", cfg.Service.Name),
30 PreRunE: func(cmd *cobra.Command, args []string) error {
31 return configlog.ReturnFatal(parser.ParseConfig(cfg))
32 },
33 RunE: func(cmd *cobra.Command, args []string) error {
34 logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
35 traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
36 if err != nil {
37 return err
38 }
39
40 // precreate folders
41 if cfg.UserSharingDriver == "json" && cfg.UserSharingDrivers.JSON.File != "" {
42 if err := os.MkdirAll(filepath.Dir(cfg.UserSharingDrivers.JSON.File), os.FileMode(0700)); err != nil {
43 return err
44 }
45 }
46 if cfg.PublicSharingDriver == "json" && cfg.PublicSharingDrivers.JSON.File != "" {
47 if err := os.MkdirAll(filepath.Dir(cfg.PublicSharingDrivers.JSON.File), os.FileMode(0700)); err != nil {
48 return err
49 }
50 }
51
52 var cancel context.CancelFunc
53 if cfg.Context == nil {
54 cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
55 defer cancel()
56 }
57 ctx := cfg.Context
58
59 gr := runner.NewGroup()
60
61 {
62 rCfg, err := revaconfig.SharingConfigFromStruct(cfg, logger)
63 if err != nil {
64 return err
65 }
66
67 // run the appropriate reva servers based on the config
68 if rServer := runtime.NewDrivenHTTPServerWithOptions(rCfg,
69 runtime.WithLogger(&logger.Logger),
70 runtime.WithRegistry(registry.GetRegistry()),
71 runtime.WithTraceProvider(traceProvider),
72 ); rServer != nil {
73 gr.Add(runner.NewRevaServiceRunner(cfg.Service.Name+".rhttp", rServer))
74 }
75 if rServer := runtime.NewDrivenGRPCServerWithOptions(rCfg,
76 runtime.WithLogger(&logger.Logger),
77 runtime.WithRegistry(registry.GetRegistry()),
78 runtime.WithTraceProvider(traceProvider),
79 ); rServer != nil {
80 gr.Add(runner.NewRevaServiceRunner(cfg.Service.Name+".rgrpc", rServer))
81 }
82 }
83

Callers 1

GetCommandsFunction · 0.70

Calls 15

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

Tested by

no test coverage detected