Use new package structuring, embed existing extensions

This commit is contained in:
Thomas Boerger
2019-12-10 15:24:01 +01:00
parent 6b6b1d8b66
commit 1612e4a841
30 changed files with 2045 additions and 278 deletions
-104
View File
@@ -1,104 +0,0 @@
package command
import (
"os"
"strings"
"github.com/owncloud/ocis/pkg/version"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// Root is the entry point for the ocis-phoenix command.
func Root() *cobra.Command {
cmd := &cobra.Command{
Use: "ocis",
Short: "ownCloud infinite scale stack",
Long: ``,
Version: version.String,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
setupLogger()
setupConfig()
},
}
cmd.PersistentFlags().String("log-level", "", "Set logging level")
viper.BindPFlag("log.level", cmd.PersistentFlags().Lookup("log-level"))
viper.SetDefault("log.level", "info")
viper.BindEnv("log.level", "HYPER_LOG_LEVEL")
cmd.PersistentFlags().Bool("log-pretty", false, "Enable pretty logging")
viper.BindPFlag("log.pretty", cmd.PersistentFlags().Lookup("log-pretty"))
viper.SetDefault("log.pretty", true)
viper.BindEnv("log.pretty", "HYPER_LOG_PRETTY")
cmd.PersistentFlags().Bool("log-color", false, "Enable colored logging")
viper.BindPFlag("log.color", cmd.PersistentFlags().Lookup("log-color"))
viper.SetDefault("log.color", true)
viper.BindEnv("log.color", "HYPER_LOG_COLOR")
cmd.AddCommand(Phoenix())
cmd.AddCommand(Webdav())
cmd.AddCommand(Ocs())
cmd.AddCommand(Health())
return cmd
}
func setupLogger() {
switch strings.ToLower(viper.GetString("log.level")) {
case "panic":
zerolog.SetGlobalLevel(zerolog.PanicLevel)
case "fatal":
zerolog.SetGlobalLevel(zerolog.FatalLevel)
case "error":
zerolog.SetGlobalLevel(zerolog.ErrorLevel)
case "warn":
zerolog.SetGlobalLevel(zerolog.WarnLevel)
case "info":
zerolog.SetGlobalLevel(zerolog.InfoLevel)
case "debug":
zerolog.SetGlobalLevel(zerolog.DebugLevel)
default:
zerolog.SetGlobalLevel(zerolog.InfoLevel)
}
if viper.GetBool("log.pretty") {
log.Logger = log.Output(
zerolog.ConsoleWriter{
Out: os.Stderr,
NoColor: !viper.GetBool("log.color"),
},
)
}
}
func setupConfig() {
viper.SetConfigName("hyper")
viper.AddConfigPath("/etc/ocis")
viper.AddConfigPath("$HOME/.ocis")
viper.AddConfigPath("./config")
if err := viper.ReadInConfig(); err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
log.Debug().
Msg("Continue without config")
case viper.UnsupportedConfigError:
log.Fatal().
Msg("Unsupported config type")
default:
if e := log.Debug(); e.Enabled() {
log.Fatal().
Err(err).
Msg("Failed to read config")
} else {
log.Fatal().
Msg("Failed to read config")
}
}
}
}
+84
View File
@@ -0,0 +1,84 @@
package command
import (
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-graph/pkg/command"
svcconfig "github.com/owncloud/ocis-graph/pkg/config"
"github.com/owncloud/ocis-graph/pkg/flagset"
"github.com/owncloud/ocis-graph/pkg/metrics"
"github.com/owncloud/ocis-graph/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// GraphCommand is the entrypoint for the graph command.
func GraphCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "graph",
Usage: "Start graph server",
Flags: flagset.ServerWithConfig(cfg.Graph),
Action: func(c *cli.Context) error {
scfg := configureGraph(cfg)
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// GraphHandler defines the direct server handler.
func GraphHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configureGraph(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configureGraph(cfg *config.Config) *svcconfig.Config {
cfg.Graph.Log.Level = cfg.Log.Level
cfg.Graph.Log.Pretty = cfg.Log.Pretty
cfg.Graph.Log.Color = cfg.Log.Color
cfg.Graph.Tracing.Enabled = false
cfg.Graph.HTTP.Root = "/"
return cfg.Graph
}
func init() {
register.AddCommand(GraphCommand)
register.AddHandler(GraphHandler)
}
+40 -18
View File
@@ -1,27 +1,49 @@
package command
import (
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"fmt"
"net/http"
"github.com/micro/cli"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
)
// Health is the entrypoint for the health command.
func Health() *cobra.Command {
cmd := &cobra.Command{
Use: "health",
Short: "Check health status",
Long: "",
Run: func(cmd *cobra.Command, args []string) {
log.Info().
Str("addr", viper.GetString("metrics.addr")).
Msg("Executed health command")
func Health(cfg *config.Config) cli.Command {
return cli.Command{
Name: "health",
Usage: "Check health status",
Flags: flagset.HealthWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
resp, err := http.Get(
fmt.Sprintf(
"http://%s/healthz",
cfg.Debug.Addr,
),
)
if err != nil {
logger.Fatal().
Err(err).
Msg("Failed to request health check")
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")
}
logger.Debug().
Int("code", resp.StatusCode).
Msg("Health got a good state")
return nil
},
}
cmd.Flags().String("metrics-addr", "", "Address to metrics endpoint")
viper.BindPFlag("metrics.addr", cmd.Flags().Lookup("metrics-addr"))
viper.BindEnv("metrics.addr", "HYPER_METRICS_ADDR")
return cmd
}
+113
View File
@@ -0,0 +1,113 @@
package command
import (
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-hello/pkg/command"
svcconfig "github.com/owncloud/ocis-hello/pkg/config"
"github.com/owncloud/ocis-hello/pkg/flagset"
"github.com/owncloud/ocis-hello/pkg/metrics"
"github.com/owncloud/ocis-hello/pkg/server/grpc"
"github.com/owncloud/ocis-hello/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// HelloCommand is the entrypoint for the hello command.
func HelloCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "hello",
Usage: "Start hello server",
Flags: flagset.ServerWithConfig(cfg.Hello),
Action: func(c *cli.Context) error {
scfg := configureHello(cfg)
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// HelloHandler defines the direct server handler.
func HelloHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configureHello(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
{
server, err := grpc.Server(
grpc.Logger(logger),
grpc.Context(ctx),
grpc.Config(scfg),
grpc.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "grpc").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "grpc").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configureHello(cfg *config.Config) *svcconfig.Config {
cfg.Hello.Log.Level = cfg.Log.Level
cfg.Hello.Log.Pretty = cfg.Log.Pretty
cfg.Hello.Log.Color = cfg.Log.Color
cfg.Hello.Tracing.Enabled = false
cfg.Hello.HTTP.Root = "/"
return cfg.Hello
}
func init() {
register.AddCommand(HelloCommand)
register.AddHandler(HelloHandler)
}
+84
View File
@@ -0,0 +1,84 @@
package command
import (
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-konnectd/pkg/command"
svcconfig "github.com/owncloud/ocis-konnectd/pkg/config"
"github.com/owncloud/ocis-konnectd/pkg/flagset"
"github.com/owncloud/ocis-konnectd/pkg/metrics"
"github.com/owncloud/ocis-konnectd/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// KonnectdCommand is the entrypoint for the konnectd command.
func KonnectdCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "konnectd",
Usage: "Start konnectd server",
Flags: flagset.ServerWithConfig(cfg.Konnectd),
Action: func(c *cli.Context) error {
scfg := configureKonnectd(cfg)
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// KonnectdHandler defines the direct server handler.
func KonnectdHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configureKonnectd(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configureKonnectd(cfg *config.Config) *svcconfig.Config {
cfg.Konnectd.Log.Level = cfg.Log.Level
cfg.Konnectd.Log.Pretty = cfg.Log.Pretty
cfg.Konnectd.Log.Color = cfg.Log.Color
cfg.Konnectd.Tracing.Enabled = false
cfg.Konnectd.HTTP.Root = "/"
return cfg.Konnectd
}
func init() {
register.AddCommand(KonnectdCommand)
register.AddHandler(KonnectdHandler)
}
+77 -8
View File
@@ -1,15 +1,84 @@
package command
import (
ocs "github.com/owncloud/ocis-ocs/pkg/command"
"github.com/spf13/cobra"
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-ocs/pkg/command"
svcconfig "github.com/owncloud/ocis-ocs/pkg/config"
"github.com/owncloud/ocis-ocs/pkg/flagset"
"github.com/owncloud/ocis-ocs/pkg/metrics"
"github.com/owncloud/ocis-ocs/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// Ocs is the entry point for the ocs command.
func Ocs() *cobra.Command {
cmd := ocs.Server()
cmd.Use = "ocs"
cmd.Short = "Start ocs server"
// OCSCommand is the entrypoint for the ocs command.
func OCSCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "ocs",
Usage: "Start ocs server",
Flags: flagset.ServerWithConfig(cfg.OCS),
Action: func(c *cli.Context) error {
scfg := configureOCS(cfg)
return cmd
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// OCSHandler defines the direct server handler.
func OCSHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configureOCS(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configureOCS(cfg *config.Config) *svcconfig.Config {
cfg.OCS.Log.Level = cfg.Log.Level
cfg.OCS.Log.Pretty = cfg.Log.Pretty
cfg.OCS.Log.Color = cfg.Log.Color
cfg.OCS.Tracing.Enabled = false
cfg.OCS.HTTP.Root = "/"
return cfg.OCS
}
func init() {
register.AddCommand(OCSCommand)
register.AddHandler(OCSHandler)
}
+77 -8
View File
@@ -1,15 +1,84 @@
package command
import (
phoenix "github.com/owncloud/ocis-phoenix/pkg/command"
"github.com/spf13/cobra"
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-phoenix/pkg/command"
svcconfig "github.com/owncloud/ocis-phoenix/pkg/config"
"github.com/owncloud/ocis-phoenix/pkg/flagset"
"github.com/owncloud/ocis-phoenix/pkg/metrics"
"github.com/owncloud/ocis-phoenix/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// Phoenix is the entry point for the phoenix command.
func Phoenix() *cobra.Command {
cmd := phoenix.Server()
cmd.Use = "phoenix"
cmd.Short = "Start phoenix server"
// PhoenixCommand is the entrypoint for the phoenix command.
func PhoenixCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "phoenix",
Usage: "Start phoenix server",
Flags: flagset.ServerWithConfig(cfg.Phoenix),
Action: func(c *cli.Context) error {
scfg := configurePhoenix(cfg)
return cmd
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// PhoenixHandler defines the direct server handler.
func PhoenixHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configurePhoenix(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configurePhoenix(cfg *config.Config) *svcconfig.Config {
cfg.Phoenix.Log.Level = cfg.Log.Level
cfg.Phoenix.Log.Pretty = cfg.Log.Pretty
cfg.Phoenix.Log.Color = cfg.Log.Color
cfg.Phoenix.Tracing.Enabled = false
cfg.Phoenix.HTTP.Root = "/"
return cfg.Phoenix
}
func init() {
register.AddCommand(PhoenixCommand)
register.AddHandler(PhoenixHandler)
}
+111
View File
@@ -0,0 +1,111 @@
package command
import (
"os"
"strings"
"github.com/micro/cli"
"github.com/owncloud/ocis-pkg/log"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
"github.com/owncloud/ocis/pkg/register"
"github.com/owncloud/ocis/pkg/version"
"github.com/spf13/viper"
)
// Execute is the entry point for the ocis-ocis command.
func Execute() error {
cfg := config.New()
app := &cli.App{
Name: "ocis",
Version: version.String,
Usage: "ownCloud Infinite Scale Stack",
Compiled: version.Compiled(),
Authors: []cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Flags: flagset.RootWithConfig(cfg),
Before: func(c *cli.Context) error {
logger := NewLogger(cfg)
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.SetEnvPrefix("OCIS")
viper.AutomaticEnv()
if c.IsSet("config-file") {
viper.SetConfigFile(c.String("config-file"))
} else {
viper.SetConfigName("ocis")
viper.AddConfigPath("/etc/ocis")
viper.AddConfigPath("$HOME/.ocis")
viper.AddConfigPath("./config")
}
if err := viper.ReadInConfig(); err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
logger.Info().
Msg("Continue without config")
case viper.UnsupportedConfigError:
logger.Fatal().
Err(err).
Msg("Unsupported config type")
default:
logger.Fatal().
Err(err).
Msg("Failed to read config")
}
}
if err := viper.Unmarshal(&cfg); err != nil {
logger.Fatal().
Err(err).
Msg("Failed to parse config")
}
return nil
},
Commands: []cli.Command{
Server(cfg),
Health(cfg),
},
}
for _, fn := range register.Commands {
app.Commands = append(
app.Commands,
fn(cfg),
)
}
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Usage: "Show the help",
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version,v",
Usage: "Print the version",
}
return app.Run(os.Args)
}
// NewLogger initializes a service-specific logger instance.
func NewLogger(cfg *config.Config) log.Logger {
return log.NewLogger(
log.Name("ocis"),
log.Level(cfg.Log.Level),
log.Pretty(cfg.Log.Pretty),
log.Color(cfg.Log.Color),
)
}
+153
View File
@@ -0,0 +1,153 @@
package command
import (
"context"
"os"
"os/signal"
"strings"
"time"
"contrib.go.opencensus.io/exporter/jaeger"
"contrib.go.opencensus.io/exporter/ocagent"
"contrib.go.opencensus.io/exporter/zipkin"
"github.com/micro/cli"
"github.com/oklog/run"
openzipkin "github.com/openzipkin/zipkin-go"
zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
"github.com/owncloud/ocis/pkg/register"
"go.opencensus.io/stats/view"
"go.opencensus.io/trace"
)
// Server is the entrypoint for the server command.
func Server(cfg *config.Config) cli.Command {
return cli.Command{
Name: "server",
Usage: "Start fullstack server",
Flags: flagset.ServerWithConfig(cfg),
Before: func(c *cli.Context) error {
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
return nil
},
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
if cfg.Tracing.Enabled {
switch t := cfg.Tracing.Type; t {
case "agent":
exporter, err := ocagent.NewExporter(
ocagent.WithReconnectionPeriod(5*time.Second),
ocagent.WithAddress(cfg.Tracing.Endpoint),
ocagent.WithServiceName(cfg.Tracing.Service),
)
if err != nil {
logger.Error().
Err(err).
Str("endpoint", cfg.Tracing.Endpoint).
Str("collector", cfg.Tracing.Collector).
Msg("Failed to create agent tracing")
return err
}
trace.RegisterExporter(exporter)
view.RegisterExporter(exporter)
case "jaeger":
exporter, err := jaeger.NewExporter(
jaeger.Options{
AgentEndpoint: cfg.Tracing.Endpoint,
CollectorEndpoint: cfg.Tracing.Collector,
ServiceName: cfg.Tracing.Service,
},
)
if err != nil {
logger.Error().
Err(err).
Str("endpoint", cfg.Tracing.Endpoint).
Str("collector", cfg.Tracing.Collector).
Msg("Failed to create jaeger tracing")
return err
}
trace.RegisterExporter(exporter)
case "zipkin":
endpoint, err := openzipkin.NewEndpoint(
cfg.Tracing.Service,
cfg.Tracing.Endpoint,
)
if err != nil {
logger.Error().
Err(err).
Str("endpoint", cfg.Tracing.Endpoint).
Str("collector", cfg.Tracing.Collector).
Msg("Failed to create zipkin tracing")
return err
}
exporter := zipkin.NewExporter(
zipkinhttp.NewReporter(
cfg.Tracing.Collector,
),
endpoint,
)
trace.RegisterExporter(exporter)
default:
logger.Warn().
Str("type", t).
Msg("Unknown tracing backend")
}
trace.ApplyConfig(
trace.Config{
DefaultSampler: trace.AlwaysSample(),
},
)
} else {
logger.Debug().
Msg("Tracing is not enabled")
}
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
)
defer cancel()
for _, fn := range register.Handlers {
fn(ctx, cancel, gr, cfg)
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
}
return gr.Run()
},
}
}
+77 -8
View File
@@ -1,15 +1,84 @@
package command
import (
webdav "github.com/owncloud/ocis-webdav/pkg/command"
"github.com/spf13/cobra"
"context"
"github.com/micro/cli"
"github.com/oklog/run"
"github.com/owncloud/ocis-webdav/pkg/command"
svcconfig "github.com/owncloud/ocis-webdav/pkg/config"
"github.com/owncloud/ocis-webdav/pkg/flagset"
"github.com/owncloud/ocis-webdav/pkg/metrics"
"github.com/owncloud/ocis-webdav/pkg/server/http"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/register"
)
// Webdav is the entry point for the webdav command.
func Webdav() *cobra.Command {
cmd := webdav.Server()
cmd.Use = "webdav"
cmd.Short = "Start webdav server"
// WebDAVCommand is the entrypoint for the webdav command.
func WebDAVCommand(cfg *config.Config) cli.Command {
return cli.Command{
Name: "webdav",
Usage: "Start webdav server",
Flags: flagset.ServerWithConfig(cfg.WebDAV),
Action: func(c *cli.Context) error {
scfg := configureWebDAV(cfg)
return cmd
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
// WebDAVHandler defines the direct server handler.
func WebDAVHandler(ctx context.Context, cancel context.CancelFunc, gr run.Group, cfg *config.Config) error {
scfg := configureWebDAV(cfg)
logger := command.NewLogger(scfg)
m := metrics.New()
{
server, err := http.Server(
http.Logger(logger),
http.Context(ctx),
http.Config(scfg),
http.Metrics(m),
)
if err != nil {
logger.Info().
Err(err).
Str("transport", "http").
Msg("Failed to initialize server")
return err
}
gr.Add(func() error {
return server.Run()
}, func(_ error) {
logger.Info().
Str("transport", "http").
Msg("Shutting down server")
cancel()
})
}
return nil
}
func configureWebDAV(cfg *config.Config) *svcconfig.Config {
cfg.WebDAV.Log.Level = cfg.Log.Level
cfg.WebDAV.Log.Pretty = cfg.Log.Pretty
cfg.WebDAV.Log.Color = cfg.Log.Color
cfg.WebDAV.Tracing.Enabled = false
cfg.WebDAV.HTTP.Root = "/"
return cfg.WebDAV
}
func init() {
register.AddCommand(WebDAVCommand)
register.AddHandler(WebDAVHandler)
}