Skip to content

Commit

Permalink
fix: seq conversion not reading env in docker environment (#3130)
Browse files Browse the repository at this point in the history
* pb

* fix: Modifying other fields while setting IsPrivateChat does not take effect

* fix: quote message error revoke

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* refactoring scheduled tasks

* upgrading pkg tools

* fix

* fix

* optimize log output

* feat: support GetLastMessage

* feat: support GetLastMessage

* feat: s3 switch

* feat: s3 switch

* fix: GetUsersOnline

* feat: SendBusinessNotification supported configuration parameters

* feat: SendBusinessNotification supported configuration parameters

* feat: SendBusinessNotification supported configuration parameters

* feat: seq conversion failed without exiting

* fix: DeleteDoc crash

* fix: fill send time

* fix: fill send time

* fix: crash caused by withdrawing messages from users who have left the group

* fix: user msg timestamp

* seq read config

* seq read config
  • Loading branch information
withchao authored and OpenIM-Robot committed Feb 10, 2025
1 parent 53316b8 commit 22d19fd
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions tools/seq/internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ import (
"context"
"errors"
"fmt"
"github.com/openimsdk/open-im-server/v3/pkg/common/cmd"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/redisutil"
"github.com/redis/go-redis/v9"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"gopkg.in/yaml.v3"
"os"
"os/signal"
"path/filepath"
Expand All @@ -24,6 +14,17 @@ import (
"sync/atomic"
"syscall"
"time"

"github.com/mitchellh/mapstructure"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
"github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/redisutil"
"github.com/redis/go-redis/v9"
"github.com/spf13/viper"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)

const (
Expand All @@ -41,12 +42,22 @@ const (
)

func readConfig[T any](dir string, name string) (*T, error) {
data, err := os.ReadFile(filepath.Join(dir, name))
if err != nil {
if runtimeenv.PrintRuntimeEnvironment() == config.KUBERNETES {

Check failure on line 45 in tools/seq/internal/main.go

View workflow job for this annotation

GitHub Actions / Benchmark Test with go 1.22.x on ubuntu-latest

undefined: runtimeenv

Check failure on line 45 in tools/seq/internal/main.go

View workflow job for this annotation

GitHub Actions / Benchmark Test with go 1.22.x on ubuntu-latest

undefined: runtimeenv

Check failure on line 45 in tools/seq/internal/main.go

View workflow job for this annotation

GitHub Actions / Benchmark Test with go 1.22.x on ubuntu-latest

undefined: runtimeenv

Check failure on line 45 in tools/seq/internal/main.go

View workflow job for this annotation

GitHub Actions / Benchmark Test with go 1.22.x on ubuntu-latest

undefined: runtimeenv
dir = os.Getenv(config.MountConfigFilePath)
}
v := viper.New()
v.SetEnvPrefix(config.EnvPrefixMap[name])
v.AutomaticEnv()
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.SetConfigFile(filepath.Join(dir, name))
if err := v.ReadInConfig(); err != nil {
return nil, err
}
fn := func(config *mapstructure.DecoderConfig) {
config.TagName = "mapstructure"
}
var conf T
if err := yaml.Unmarshal(data, &conf); err != nil {
if err := v.Unmarshal(&conf, fn); err != nil {
return nil, err
}
return &conf, nil
Expand Down

0 comments on commit 22d19fd

Please sign in to comment.