Files
ocis/pkg/command/server_simple.go
T

69 lines
1.5 KiB
Go
Raw Normal View History

2020-01-09 14:34:08 +01:00
// +build simple
package command
import (
"strings"
"github.com/micro/cli"
"github.com/micro/go-micro/config/cmd"
"github.com/owncloud/ocis/pkg/config"
"github.com/owncloud/ocis/pkg/flagset"
"github.com/owncloud/ocis/pkg/micro/runtime"
"github.com/owncloud/ocis/pkg/register"
2020-01-10 11:48:09 +01:00
"github.com/owncloud/ocis/pkg/tracing"
2020-01-09 14:34:08 +01:00
)
2020-01-10 11:59:19 +01:00
var (
2020-01-10 12:02:11 +01:00
// SimpleRuntimeServices declares which services will be started for the fullstack server
2020-01-16 22:34:25 +01:00
SimpleRuntimeServices = []string{
"hello",
"phoenix",
"reva-frontend",
"reva-gateway",
"reva-users",
"reva-auth-basic",
"reva-auth-bearer",
}
2020-01-10 11:59:19 +01:00
)
// Simple is the entrypoint for the server command. It is the `ocis server` subcommand overloaded with a different set of services
2020-01-09 14:34:08 +01:00
func Simple(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:48:09 +01:00
return err
2020-01-09 14:34:08 +01:00
}
runtime := runtime.New(
runtime.Logger(logger),
2020-01-10 11:59:19 +01:00
runtime.Services(append(runtime.RuntimeServices, SimpleRuntimeServices...)),
2020-01-09 14:34:08 +01:00
runtime.MicroRuntime(cmd.DefaultCmd.Options().Runtime),
)
2020-01-10 11:59:19 +01:00
{
runtime.Start()
runtime.Trap()
}
2020-01-09 14:34:08 +01:00
return nil
},
}
}
func init() {
register.AddCommand(Simple)
}