forked from bigbluebutton/bigbluebutton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor (build/gql-middleware): Introduce config as a yml file (bigb…
…luebutton#20992) * Introduce Gql-Middleware config as a yml file * use path /usr/share/bbb-graphql-middleware/ instead of /usr/local/bigbluebutton/bbb-graphql-middleware * remove /etc/default/bbb-graphql-middleware file
- Loading branch information
1 parent
9cee20c
commit e140714
Showing
19 changed files
with
211 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package config | ||
|
||
import ( | ||
"dario.cat/mergo" | ||
log "github.com/sirupsen/logrus" | ||
"gopkg.in/yaml.v3" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"sync" | ||
) | ||
|
||
var ( | ||
instance *Config | ||
once sync.Once | ||
) | ||
|
||
var DefaultConfigPath = "/usr/share/bbb-graphql-middleware/config.yml" | ||
var OverrideConfigPath = "/etc/bigbluebutton/bbb-graphql-middleware.yml" | ||
|
||
type Config struct { | ||
Server struct { | ||
Host string `yaml:"listen_host"` | ||
Port int `yaml:"listen_port"` | ||
MaxConnections int `yaml:"max_connections"` | ||
MaxConnectionsPerSecond int `yaml:"max_connections_per_session_token"` | ||
MaxConnectionsPerSessionToken int `yaml:"max_connections_per_second"` | ||
AuthorizedCrossOrigin string `yaml:"authorized_cross_origin"` | ||
JsonPatchDisabled bool `yaml:"json_patch_disabled"` | ||
SubscriptionAllowedList string `yaml:"subscriptions_allowed_list"` | ||
SubscriptionsDeniedList string `yaml:"subscriptions_denied_list"` | ||
} `yaml:"server"` | ||
Redis struct { | ||
Host string `yaml:"host"` | ||
Port int32 `yaml:"port"` | ||
Password string `yaml:"password"` | ||
} `yaml:"redis"` | ||
Hasura struct { | ||
Url string `yaml:"url"` | ||
} `yaml:"hasura"` | ||
GraphqlActions struct { | ||
Url string `yaml:"url"` | ||
} `yaml:"graphql-actions"` | ||
AuthHook struct { | ||
Url string `yaml:"url"` | ||
} `yaml:"auth_hook"` | ||
SessionVarsHook struct { | ||
Url string `yaml:"url"` | ||
} `yaml:"session_vars_hook"` | ||
LogLevel string `yaml:"log_level"` | ||
PrometheusAdvancedMetricsEnabled bool `yaml:"prometheus_advanced_metrics_enabled"` | ||
} | ||
|
||
func GetConfig() *Config { | ||
once.Do(func() { | ||
instance = &Config{} | ||
instance.loadConfigs() | ||
}) | ||
return instance | ||
} | ||
|
||
func (c *Config) loadConfigs() { | ||
// Load default config file | ||
configDefault, err := loadConfigFile(DefaultConfigPath) | ||
if err != nil { | ||
log.Fatalf("Error while loading config file (%s): %v", DefaultConfigPath, err) | ||
} | ||
|
||
// Load override config file if exists | ||
if _, err := os.Stat(OverrideConfigPath); err == nil { | ||
configOverride, err := loadConfigFile(OverrideConfigPath) | ||
if err != nil { | ||
log.Fatalf("Error while loading override config file (%s): %v", OverrideConfigPath, err) | ||
} | ||
|
||
log.Info("Override config found at " + OverrideConfigPath) | ||
|
||
// Use mergo to merge configs | ||
err = mergo.Merge(&configDefault, configOverride, mergo.WithOverride) | ||
if err != nil { | ||
log.Fatalf("Erro ao mesclar as configurações: %v", err) | ||
} | ||
} | ||
|
||
// Update the singleton instance with the merged config | ||
*instance = configDefault | ||
} | ||
|
||
func loadConfigFile(path string) (Config, error) { | ||
var config Config | ||
data, err := ioutil.ReadFile(filepath.Clean(path)) | ||
if err != nil { | ||
return config, err | ||
} | ||
|
||
err = yaml.Unmarshal(data, &config) | ||
if err != nil { | ||
return config, err | ||
} | ||
|
||
return config, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
server: | ||
listen_host: 127.0.0.1 | ||
listen_port: 8378 | ||
#max of concurrent connections | ||
max_connections: 500 | ||
max_connections_per_session_token: 3 | ||
#rate limit | ||
max_connections_per_second: 100 | ||
# If you are running a cluster proxy setup, you need to allow the url of the Frontend | ||
# Add an Authorized Cross Origin. See https://docs.bigbluebutton.org/administration/cluster-proxy | ||
#authorized_cross_origin: 'bbb-proxy.example.com' | ||
json_patch_disabled: false | ||
subscriptions_allowed_list: | ||
subscriptions_denied_list: | ||
redis: | ||
host: 127.0.0.1 | ||
port: 6379 | ||
password: "" | ||
hasura: | ||
url: ws://127.0.0.1:8085/v1/graphql | ||
graphql-actions: | ||
url: http://127.0.0.1:8093 | ||
auth_hook: | ||
url: http://127.0.0.1:8090/bigbluebutton/connection/checkGraphqlAuthorization | ||
session_vars_hook: | ||
url: http://127.0.0.1:8901/userInfo | ||
prometheus_advanced_metrics_enabled: false | ||
log_level: INFO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
bbb-graphql-middleware/internal/common/PrometheusMetrics.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.