2020-01-09 14:33:44 +01:00
|
|
|
// +build !simple
|
|
|
|
|
|
2019-12-10 15:24:01 +01:00
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
|
2020-02-10 17:04:40 +01:00
|
|
|
"github.com/micro/cli/v2"
|
2019-12-10 15:24:01 +01:00
|
|
|
"github.com/owncloud/ocis/pkg/config"
|
|
|
|
|
"github.com/owncloud/ocis/pkg/flagset"
|
2020-01-09 14:33:44 +01:00
|
|
|
"github.com/owncloud/ocis/pkg/register"
|
2020-06-04 11:45:19 +02:00
|
|
|
"github.com/owncloud/ocis/pkg/runtime"
|
2020-01-10 11:49:25 +01:00
|
|
|
"github.com/owncloud/ocis/pkg/tracing"
|
2019-12-10 15:24:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 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{
|
2019-12-17 11:43:58 +01:00
|
|
|
Name: "server",
|
|
|
|
|
Usage: "Start fullstack server",
|
|
|
|
|
Category: "Fullstack",
|
|
|
|
|
Flags: flagset.ServerWithConfig(cfg),
|
2019-12-10 15:24:01 +01:00
|
|
|
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 {
|
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-10 15:24:01 +01:00
|
|
|
}
|
|
|
|
|
|
2020-06-04 12:27:40 +02:00
|
|
|
r := runtime.New()
|
|
|
|
|
return r.Start(append(runtime.Extensions, runtime.MicroServices...)...)
|
2019-12-17 11:43:58 +01:00
|
|
|
},
|
|
|
|
|
}
|
2019-12-10 15:24:01 +01:00
|
|
|
}
|
2020-01-09 14:33:44 +01:00
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
register.AddCommand(Server)
|
|
|
|
|
}
|