mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-05 20:11:14 +08:00
* Code adaptation k8s: service discovery and registration adaptation, configuration adaptation * Initial submission of the help charts script for openim API * change the help charts script * change the help charts script * change helm chart codes * change dockerfiles script * change chart script:add configmap mounts * change chart script:change repository * change chart script:msggateway add one service * change config.yaml * roll back some config values * change chart script:change Ingress rule with a rewrite annotation * add mysql charts scrible * change chart script:add mysql.config.yaml * add nfs provisioner charts * change chart script:add nfs.config.yaml * add ingress-nginx charts * change chart script:add ingress-nginx.config.yaml * add redis &mongodb charts * add kafka&minio charts * change chart script:change redis.values.yaml * change chart script:add redis.config.yaml * change chart script:change redis.config.yaml * change chart script:change mongodb.value.yaml * change chart script:change mongodb.value.yaml * change chart script:add mongodb.config.yaml * change chart script:change minio.values.yaml * change chart script:add minio.config.yaml * change chart script:change kafka.values.yaml * change chart script:add kafka.config.yaml * change chart script:change services.config.yaml * bug fix:Delete websocket's Port restrictions * bug fix:change port value * change chart script:Submit a stable version script * fix bug:Implement option interface * fix bug:change K8sDR.Register * change config.yaml * change chats script:minio service add ingress * change chats script:minio service add ingress * change chats script:kafka.replicaCount=3& change minio.api ingress * delete change chats script * change config.yaml * change openim.yaml * merge go.sum * Add monitoring function and struct for Prometheus on gin and GRPC * Add GRPC and gin server monitoring logic * Add GRPC and gin server monitoring logic2 * Add GRPC and gin server monitoring logic3 * Add GRPC and gin server monitoring logic4 * Add GRPC and gin server monitoring logic5 * Add GRPC and gin server monitoring logic6 * Add GRPC and gin server monitoring logic7 * delete:old monitoring code * add for test * fix bug:change packname * fix bug:delete getPromPort funciton * fix bug:delete getPromPort funciton * fix bug:change logs * fix bug:change registerName logic in GetGrpcCusMetrics function * add getPrometheus url api * fix:config path logic * fix:prometheus enable function * fix:prometheus enable function * fix:transfer Multi process monitoring logic * del:del not using manifest * fix:openim-msgtransfer.sh * fix:openim-msgtransfer.sh * cicd: robot automated Change * delete not using files * add prometheus docker-compose for monitor * fix prometheus.yaml * fix environment.sh * fix init-config.sh * fix init-config.sh * fix env_template.yaml * fix docker-compose.yml * fix docker-compose.yml * add openim_admin_front service * change openim-admin-front * del not using files * add node-exporter-dashaboard.yaml * cicd: robot automated Change * cicd: robot automated Change * feature: add alertmanager function * feature: add alertmanager function * feature: add alertmanager function * feature: add alertmanager function * feature: add alertmanager function * del:delete not using files * del:delete not using files * change:change to personal email info * feat: deployment and design of management backend and monitoring Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: deployment and design of management backend and monitoring Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> * feat: deployment and design of management backend and monitoring Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> --------- Signed-off-by: Xinwei Xiong(cubxxw) <3293172751nss@gmail.com> Co-authored-by: lin.huang <lin.huang@apulis.com> Co-authored-by: xuexihuang <1339326187@qq.com> Co-authored-by: xuexihuang <xuexihuang@users.noreply.github.com> Co-authored-by: cubxxw <cubxxw@users.noreply.github.com>
71 lines
2.6 KiB
Go
71 lines
2.6 KiB
Go
package config
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
)
|
|
|
|
// Flags is the flag set that AddOptions adds to. Test authors should
|
|
// also use it instead of directly adding to the global command line.
|
|
var Flags = flag.NewFlagSet("", flag.ContinueOnError)
|
|
|
|
// CopyFlags ensures that all flags that are defined in the source flag
|
|
// set appear in the target flag set as if they had been defined there
|
|
// directly. From the flag package it inherits the behavior that there
|
|
// is a panic if the target already contains a flag from the source.
|
|
func CopyFlags(source *flag.FlagSet, target *flag.FlagSet) {
|
|
source.VisitAll(func(flag *flag.Flag) {
|
|
// We don't need to copy flag.DefValue. The original
|
|
// default (from, say, flag.String) was stored in
|
|
// the value and gets extracted by Var for the help
|
|
// message.
|
|
target.Var(flag.Value, flag.Name, flag.Usage)
|
|
})
|
|
}
|
|
|
|
// Config defines the configuration structure for the OpenIM components.
|
|
type Config struct {
|
|
APIHost string
|
|
APIPort string
|
|
MsgGatewayHost string
|
|
MsgTransferHost string
|
|
PushHost string
|
|
RPCAuthHost string
|
|
RPCConversationHost string
|
|
RPCFriendHost string
|
|
RPCGroupHost string
|
|
RPCMsgHost string
|
|
RPCThirdHost string
|
|
RPCUserHost string
|
|
// Add other configuration fields as needed
|
|
}
|
|
|
|
// LoadConfig loads the configurations from environment variables or default values.
|
|
func LoadConfig() *Config {
|
|
return &Config{
|
|
APIHost: getEnv("OPENIM_API_HOST", "127.0.0.1"),
|
|
APIPort: getEnv("API_OPENIM_PORT", "10002"),
|
|
|
|
// TODO: Set default variable
|
|
MsgGatewayHost: getEnv("OPENIM_MSGGATEWAY_HOST", "default-msggateway-host"),
|
|
MsgTransferHost: getEnv("OPENIM_MSGTRANSFER_HOST", "default-msgtransfer-host"),
|
|
PushHost: getEnv("OPENIM_PUSH_HOST", "default-push-host"),
|
|
RPCAuthHost: getEnv("OPENIM_RPC_AUTH_HOST", "default-rpc-auth-host"),
|
|
RPCConversationHost: getEnv("OPENIM_RPC_CONVERSATION_HOST", "default-rpc-conversation-host"),
|
|
RPCFriendHost: getEnv("OPENIM_RPC_FRIEND_HOST", "default-rpc-friend-host"),
|
|
RPCGroupHost: getEnv("OPENIM_RPC_GROUP_HOST", "default-rpc-group-host"),
|
|
RPCMsgHost: getEnv("OPENIM_RPC_MSG_HOST", "default-rpc-msg-host"),
|
|
RPCThirdHost: getEnv("OPENIM_RPC_THIRD_HOST", "default-rpc-third-host"),
|
|
RPCUserHost: getEnv("OPENIM_RPC_USER_HOST", "default-rpc-user-host"),
|
|
}
|
|
}
|
|
|
|
// getEnv is a helper function to read an environment variable or return a default value.
|
|
func getEnv(key, defaultValue string) string {
|
|
value, exists := os.LookupEnv(key)
|
|
if !exists {
|
|
return defaultValue
|
|
}
|
|
return value
|
|
}
|