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

Function Server

services/postprocessing/pkg/command/server.go:23–101  ·  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 %s service without runtime (unsupervised mode)", cfg.Service.Name),
27 PreRunE: func(cmd *cobra.Command, args []string) error {
28 err := parser.ParseConfig(cfg)
29 if err != nil {
30 fmt.Printf("%v", err)
31 os.Exit(1)
32 }
33 return err
34 },
35 RunE: func(cmd *cobra.Command, args []string) error {
36 logger := log.Configure(cfg.Service.Name, cfg.Commons, cfg.LogLevel)
37
38 var cancel context.CancelFunc
39 if cfg.Context == nil {
40 cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...)
41 defer cancel()
42 }
43 ctx := cfg.Context
44
45 traceProvider, err := tracing.GetTraceProvider(cmd.Context(), cfg.Commons.TracesExporter, cfg.Service.Name)
46 if err != nil {
47 return err
48 }
49
50 gr := runner.NewGroup()
51 {
52 st := store.Create(
53 store.Store(cfg.Store.Store),
54 store.TTL(cfg.Store.TTL),
55 microstore.Nodes(cfg.Store.Nodes...),
56 microstore.Database(cfg.Store.Database),
57 microstore.Table(cfg.Store.Table),
58 store.Authentication(cfg.Store.AuthUsername, cfg.Store.AuthPassword),
59 store.TLSEnabled(cfg.Store.EnableTLS),
60 store.TLSInsecure(cfg.Store.TLSInsecure),
61 store.TLSRootCA(cfg.Store.TLSRootCACertificate),
62 )
63
64 svc, err := service.NewPostprocessingService(ctx, logger, st, traceProvider, cfg)
65 if err != nil {
66 return err
67 }
68
69 gr.Add(runner.New(cfg.Service.Name+".svc", func() error {
70 return svc.Run()
71 }, func() {
72 svc.Close()
73 }))
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

RunMethod · 0.95
CloseMethod · 0.95
ParseConfigFunction · 0.92
ConfigureFunction · 0.92
GetTraceProviderFunction · 0.92
NewGroupFunction · 0.92
NewPostprocessingServiceFunction · 0.92
NewFunction · 0.92
ServerFunction · 0.92
LoggerFunction · 0.92
ContextFunction · 0.92
ConfigFunction · 0.92

Tested by

no test coverage detected