mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-02 02:11:18 -06:00
rename default services
This commit is contained in:
@@ -76,6 +76,7 @@ func Execute() error {
|
||||
},
|
||||
}
|
||||
|
||||
// Load commands from the registry
|
||||
for _, fn := range register.Commands {
|
||||
app.Commands = append(
|
||||
app.Commands,
|
||||
@@ -83,11 +84,7 @@ func Execute() error {
|
||||
)
|
||||
}
|
||||
|
||||
runtime.AddRuntime(app)
|
||||
app.Commands = append(
|
||||
app.Commands,
|
||||
runtime.Command(app),
|
||||
)
|
||||
runtime.AddMicroPlatform(app)
|
||||
|
||||
cli.HelpFlag = &cli.BoolFlag{
|
||||
Name: "help,h",
|
||||
@@ -102,7 +99,7 @@ func Execute() error {
|
||||
return app.Run(os.Args)
|
||||
}
|
||||
|
||||
// NewLogger initializes a service-specific logger instance.
|
||||
// NewLogger initializes a service-specific logger instance
|
||||
func NewLogger(cfg *config.Config) log.Logger {
|
||||
return log.NewLogger(
|
||||
log.Name("ocis"),
|
||||
|
||||
@@ -36,15 +36,12 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
runtime := runtime.New(
|
||||
runtime.Services(append(runtime.RuntimeServices, runtime.Extensions...)),
|
||||
runtime.Services(append(runtime.MicroServices, runtime.Extensions...)),
|
||||
runtime.Logger(logger),
|
||||
runtime.MicroRuntime(cmd.DefaultCmd.Options().Runtime),
|
||||
)
|
||||
|
||||
// fork uses the micro runtime to fork go-micro services
|
||||
runtime.Start()
|
||||
|
||||
// trap blocks until a kill signal is sent
|
||||
runtime.Trap()
|
||||
|
||||
return nil
|
||||
|
||||
@@ -14,7 +14,7 @@ func Command(app *cli.App) *cli.Command {
|
||||
Category: "Micro",
|
||||
Action: func(c *cli.Context) error {
|
||||
runtime := New(
|
||||
Services(RuntimeServices),
|
||||
Services(MicroServices),
|
||||
Logger(log.NewLogger()),
|
||||
MicroRuntime(cmd.DefaultCmd.Options().Runtime),
|
||||
)
|
||||
|
||||
@@ -15,40 +15,42 @@ import (
|
||||
"github.com/owncloud/ocis-pkg/v2/log"
|
||||
)
|
||||
|
||||
// OwncloudNamespace is the base path for micro' services to use
|
||||
var OwncloudNamespace = "com.owncloud."
|
||||
var (
|
||||
// OwncloudNamespace is the base path for micro' services to use
|
||||
OwncloudNamespace = "com.owncloud."
|
||||
|
||||
// RuntimeServices to start as part of the fullstack option
|
||||
var RuntimeServices = []string{
|
||||
"api", // :8080
|
||||
"proxy", // :8081
|
||||
"web", // :8082
|
||||
"registry", // :8000
|
||||
"runtime", // :8088 (future proof. We want to be able to control extensions through a runtime)
|
||||
}
|
||||
// MicroServices to start as part of the fullstack option
|
||||
MicroServices = []string{
|
||||
"api", // :8080
|
||||
"proxy", // :8081
|
||||
"web", // :8082
|
||||
"registry", // :8000
|
||||
"runtime", // :8088 (future proof. We want to be able to control extensions through a runtime)
|
||||
}
|
||||
|
||||
// Extensions are ocis extension services
|
||||
var Extensions = []string{
|
||||
"hello",
|
||||
"phoenix",
|
||||
"graph",
|
||||
"graph-explorer",
|
||||
"ocs",
|
||||
"webdav",
|
||||
"reva-frontend",
|
||||
"reva-gateway",
|
||||
"reva-users",
|
||||
"reva-auth-basic",
|
||||
"reva-auth-bearer",
|
||||
"reva-sharing",
|
||||
"reva-storage-root",
|
||||
"reva-storage-home",
|
||||
"reva-storage-home-data",
|
||||
"reva-storage-oc",
|
||||
"reva-storage-oc-data",
|
||||
"devldap",
|
||||
"konnectd",
|
||||
}
|
||||
// Extensions are ocis extension services
|
||||
Extensions = []string{
|
||||
"hello",
|
||||
"phoenix",
|
||||
"graph",
|
||||
"graph-explorer",
|
||||
"ocs",
|
||||
"webdav",
|
||||
"reva-frontend",
|
||||
"reva-gateway",
|
||||
"reva-users",
|
||||
"reva-auth-basic",
|
||||
"reva-auth-bearer",
|
||||
"reva-sharing",
|
||||
"reva-storage-root",
|
||||
"reva-storage-home",
|
||||
"reva-storage-home-data",
|
||||
"reva-storage-oc",
|
||||
"reva-storage-oc-data",
|
||||
"devldap",
|
||||
"konnectd",
|
||||
}
|
||||
)
|
||||
|
||||
// Runtime is a wrapper around micro's own runtime
|
||||
type Runtime struct {
|
||||
@@ -67,15 +69,15 @@ func New(opts ...Option) Runtime {
|
||||
R: options.MicroRuntime,
|
||||
}
|
||||
|
||||
for _, v := range append(RuntimeServices, Extensions...) {
|
||||
for _, v := range append(MicroServices, Extensions...) {
|
||||
r.services = append(r.services, &gorun.Service{Name: v})
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// Trap waits for a sigkill to stop the runtime
|
||||
func (r *Runtime) Trap() {
|
||||
// Trap listen and blocks for termination signals
|
||||
func (r Runtime) Trap() {
|
||||
shutdown := make(chan os.Signal, 1)
|
||||
signal.Notify(shutdown, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT)
|
||||
|
||||
@@ -83,19 +85,20 @@ func (r *Runtime) Trap() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// block until there is a value
|
||||
for range shutdown {
|
||||
r.Logger.Info().Msg("shutdown signal received")
|
||||
close(shutdown)
|
||||
}
|
||||
|
||||
if err := (*r.R).Stop(); err != nil {
|
||||
r.Logger.Err(err)
|
||||
r.Logger.Err(err).Msgf("error while shutting down")
|
||||
}
|
||||
|
||||
for _, v := range r.services {
|
||||
r.Logger.Info().Msgf("gracefully stopping service %v", v.Name)
|
||||
(*r.R).Delete(v)
|
||||
for _, s := range r.services {
|
||||
r.Logger.Info().Msgf("gracefully stopping service %v", s.Name)
|
||||
if err := (*r.R).Delete(s); err != nil {
|
||||
r.Logger.Err(err).Msgf("error while deleting service: %v", s.Name)
|
||||
}
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
@@ -106,7 +109,8 @@ func (r *Runtime) Start() {
|
||||
env := os.Environ()
|
||||
|
||||
for _, service := range r.services {
|
||||
r.Logger.Info().Msgf("args: %v %v", os.Args[0], service.Name) // TODO uncommenting this line causes some issues where the binary calls itself with the `server` as argument
|
||||
// TODO uncommenting this line causes some issues where the binary calls itself with the `server` as argument
|
||||
r.Logger.Info().Msgf("args: %v %v", os.Args[0], service.Name)
|
||||
args := []gorun.CreateOption{
|
||||
gorun.WithCommand(os.Args[0], service.Name),
|
||||
gorun.WithEnv(env),
|
||||
@@ -119,8 +123,8 @@ func (r *Runtime) Start() {
|
||||
}
|
||||
}
|
||||
|
||||
// AddRuntime adds the micro subcommands to the cli app
|
||||
func AddRuntime(app *cli.App) {
|
||||
// AddMicroPlatform adds the micro subcommands to the cli app
|
||||
func AddMicroPlatform(app *cli.App) {
|
||||
setDefaults()
|
||||
|
||||
app.Commands = append(app.Commands, api.Commands()...)
|
||||
|
||||
Reference in New Issue
Block a user