cherrypick extensions to start v1

This commit is contained in:
A.Unger
2021-06-29 15:28:19 +02:00
parent f02f2a3d42
commit 2e28582c1b
34 changed files with 156 additions and 4 deletions
+4
View File
@@ -28,6 +28,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"ACCOUNTS_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"GLAUTH_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -27,6 +27,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"GRAPH_EXPLORER_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -34,6 +34,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"GRAPH_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"IDP_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+3 -2
View File
@@ -70,8 +70,9 @@ type Mode int
// Runtime configures the oCIS runtime when running in supervised mode.
type Runtime struct {
Port string
Host string
Port string
Host string
Extensions string
}
// Config combines all available configuration parts.
+7
View File
@@ -162,5 +162,12 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"OCIS_GRPC_ADDR"},
Destination: &cfg.GRPC.Addr,
},
&cli.StringFlag{
Name: "extensions",
Aliases: []string{"e"},
Usage: "Run specific extensions during supervised mode",
EnvVars: []string{"OCIS_RUN_EXTENSIONS"},
Destination: &cfg.Runtime.Extensions,
},
}
}
+42 -2
View File
@@ -22,6 +22,7 @@ import (
graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/command"
graph "github.com/owncloud/ocis/graph/pkg/command"
idp "github.com/owncloud/ocis/idp/pkg/command"
"github.com/owncloud/ocis/ocis-pkg/config"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
ocs "github.com/owncloud/ocis/ocs/pkg/command"
@@ -37,6 +38,11 @@ import (
"github.com/thejerf/suture/v4"
)
var (
// runset keeps track of which extensions to start supervised.
runset []string
)
// Service represents a RPC service.
type Service struct {
Supervisor *suture.Supervisor
@@ -180,7 +186,18 @@ func Start(o ...Option) error {
}
}()
for name := range s.ServicesRegistry {
// prepare runset
s.generateRunSet(s.cfg)
for _, name := range runset {
// skip delayed services for now
if _, ok := s.Delayed[name]; ok {
continue
}
// we do this so each service has its own copy. In a perfect world a config object should NOT be edited by
// the callers because this might trigger behavioral changes up the tree.
swap := deepcopy.Copy(s.cfg)
s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config))))
}
@@ -198,7 +215,12 @@ func Start(o ...Option) error {
time.Sleep(1 * time.Second)
// add services with delayed execution.
for name := range s.Delayed {
for _, name := range runset {
// this time around only run delayed jobs
if _, ok := s.Delayed[name]; !ok {
continue
}
swap := deepcopy.Copy(s.cfg)
s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config))))
}
@@ -206,6 +228,24 @@ func Start(o ...Option) error {
return http.Serve(l, nil)
}
func (s *Service) generateRunSet(cfg *config.Config) {
if cfg.Runtime.Extensions != "" {
e := strings.Split(strings.Replace(cfg.Runtime.Extensions, " ", "", -1), ",")
for i := range e {
runset = append(runset, e[i])
}
return
}
for name := range s.ServicesRegistry {
runset = append(runset, name)
}
for name := range s.Delayed {
runset = append(runset, name)
}
}
// Start indicates the Service Controller to start a new supervised service as an OS thread.
func (s *Service) Start(name string, reply *int) error {
// RPC calls to a Service object will allow for parsing config. Mind that since the runtime is running on a different
+4
View File
@@ -179,6 +179,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"OCS_STORAGE_USERS_DRIVER", "STORAGE_USERS_DRIVER"},
Destination: &cfg.StorageUsersDriver,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -34,6 +34,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"ONLYOFFICE_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -30,6 +30,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"PROXY_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -27,6 +27,10 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"SETTINGS_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+1
View File
@@ -76,6 +76,7 @@ func AuthBasicWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, LDAPWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+1
View File
@@ -102,6 +102,7 @@ func AuthBearerWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+4
View File
@@ -131,5 +131,9 @@ func DriverEOSWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_DRIVER_EOS_GATEWAYSVC"},
Destination: &cfg.Reva.Storages.EOS.GatewaySVC,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -16,5 +16,9 @@ func DriverLocalWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_DRIVER_LOCAL_ROOT"},
Destination: &cfg.Reva.Storages.Local.Root,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -37,5 +37,9 @@ func DriverOCISWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_DRIVER_OCIS_SERVICE_USER_UUID"},
Destination: &cfg.Reva.Storages.OCIS.ServiceUserUUID,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -58,5 +58,9 @@ func DriverOwnCloudWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_DRIVER_OWNCLOUD_LAYOUT"},
Destination: &cfg.Reva.Storages.OwnCloud.UserLayout,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -65,5 +65,9 @@ func DriverS3NGWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_DRIVER_S3NG_BUCKET"},
Destination: &cfg.Reva.Storages.S3NG.Bucket,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+1
View File
@@ -183,6 +183,7 @@ func FrontendWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+1
View File
@@ -264,6 +264,7 @@ func GatewayWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+1
View File
@@ -79,6 +79,7 @@ func GroupsWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, LDAPWithConfig(cfg)...)
flags = append(flags, RestWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+4
View File
@@ -208,5 +208,9 @@ func LDAPWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_LDAP_GROUP_SCHEMA_GID_NUMBER"},
Destination: &cfg.Reva.LDAP.GroupSchema.GIDNumber,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -72,5 +72,9 @@ func RestWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_REST_TARGET_API"},
Destination: &cfg.Reva.UserGroupRest.TargetAPI,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+4
View File
@@ -33,5 +33,9 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_LOG_COLOR", "OCIS_LOG_COLOR"},
Destination: &cfg.Log.Color,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+16
View File
@@ -0,0 +1,16 @@
package flagset
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/storage/pkg/config"
)
// RuntimeConfig applies common debug config cfg to the flagset
func RuntimeConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+1
View File
@@ -98,6 +98,7 @@ func SharingWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, SharingSQLWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+4
View File
@@ -44,5 +44,9 @@ func SharingSQLWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_SHARING_USER_SQL_NAME"},
Destination: &cfg.Reva.Sharing.UserSQLName,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}
+1
View File
@@ -157,6 +157,7 @@ func StorageHomeWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
flags = append(flags, DriverS3NGWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+2
View File
@@ -106,6 +106,8 @@ func StorageMetadata(cfg *config.Config) []cli.Flag {
f = append(f, DriverOwnCloudWithConfig(cfg)...)
f = append(f, DriverOCISWithConfig(cfg)...)
f = append(f, DriverS3NGWithConfig(cfg)...)
f = append(f, RuntimeConfig(cfg)...)
return f
}
+1
View File
@@ -53,6 +53,7 @@ func StoragePublicLink(cfg *config.Config) []cli.Flag {
flags = append(flags, TracingWithConfig(cfg)...)
flags = append(flags, DebugWithConfig(cfg)...)
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+1
View File
@@ -147,6 +147,7 @@ func StorageUsersWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, DriverOwnCloudWithConfig(cfg)...)
flags = append(flags, DriverOCISWithConfig(cfg)...)
flags = append(flags, DriverS3NGWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+1
View File
@@ -79,6 +79,7 @@ func UsersWithConfig(cfg *config.Config) []cli.Flag {
flags = append(flags, SecretWithConfig(cfg)...)
flags = append(flags, LDAPWithConfig(cfg)...)
flags = append(flags, RestWithConfig(cfg)...)
flags = append(flags, RuntimeConfig(cfg)...)
return flags
}
+4
View File
@@ -169,6 +169,10 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"STORAGE_WEBDAV_NAMESPACE"},
Destination: &cfg.Thumbnail.WebdavNamespace,
},
&cli.StringFlag{
Name: "extensions",
Usage: "Run specific extensions during supervised mode",
},
}
}