Files
ocis/pkg/command/server.go
T

55 lines
1.2 KiB
Go
Raw Normal View History

2020-01-09 14:33:44 +01:00
// +build !simple
package command
import (
"strings"
2020-02-10 17:04:40 +01:00
"github.com/micro/cli/v2"
"github.com/micro/go-micro/v2/config/cmd"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
2019-12-17 14:32:58 +01:00
"github.com/owncloud/ocis/pkg/micro/runtime"
2020-01-09 14:33:44 +01:00
"github.com/owncloud/ocis/pkg/register"
2020-01-10 11:49:25 +01:00
"github.com/owncloud/ocis/pkg/tracing"
)
// Server is the entrypoint for the server command.
2020-02-10 17:04:40 +01:00
func Server(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "server",
Usage: "Start fullstack server",
Category: "Fullstack",
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)
2020-01-10 11:51:03 +01:00
if err := tracing.Start(cfg); err != nil {
2020-01-10 11:49:25 +01:00
return err
}
2019-12-17 14:32:58 +01:00
runtime := runtime.New(
2020-02-17 14:43:56 +01:00
runtime.Services(append(runtime.MicroServices, runtime.Extensions...)),
2019-12-17 14:32:58 +01:00
runtime.Logger(logger),
runtime.MicroRuntime(cmd.DefaultCmd.Options().Runtime),
2020-03-17 14:59:54 +01:00
runtime.Context(c),
2019-12-17 14:32:58 +01:00
)
2019-12-17 14:32:58 +01:00
runtime.Start()
runtime.Trap()
return nil
},
}
}
2020-01-09 14:33:44 +01:00
func init() {
register.AddCommand(Server)
}