From 95d134c2ec78539b237cf6a6bf396d31983c1721 Mon Sep 17 00:00:00 2001 From: dukai Date: Tue, 20 May 2025 13:03:17 +0800 Subject: [PATCH] update: update config --- config.yml | 19 +++++++++++++++++++ config/robotfs.go | 10 +++++++++- utils/operation.go | 16 ++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 utils/operation.go diff --git a/config.yml b/config.yml index e69de29..dd7a7b6 100644 --- a/config.yml +++ b/config.yml @@ -0,0 +1,19 @@ +robotfs: + address: "0.0.0.0:6201" + log_path: "/var/log/robotfs" + +redis: + address: "localhost:6379" + password: "" + db: 0 + +s3: + region: "us-east-1" + endpoint: "http://localhost:9000" + access_key_id: "minioadmin" + secret_access_key: "minioadmin" + bucket_name: "robotfs" + use_path_style: true + +juicefs: + data_path: "/data/juicefs" diff --git a/config/robotfs.go b/config/robotfs.go index ac8468b..6cc011c 100644 --- a/config/robotfs.go +++ b/config/robotfs.go @@ -8,7 +8,9 @@ type RobotFSConfig struct { type RedisConfig struct { Address string `mapstructure:"address"` Password string `mapstructure:"password"` - DB int `mapstructure:"db"` + DataBase int `mapstructure:"database"` + //Todo: use it in the future + SuperLargeDirectories []string `mapstructure:"superLargeDirectories"` } type S3Config struct { @@ -20,10 +22,16 @@ type S3Config struct { UsePathStyle bool `mapstructure:"use_path_style"` } +type JuicefsConfig struct { + //Address string `mapstructure:"address"` + DataPath string `mapstructure:"data_path"` +} + type Config struct { RobotFS RobotFSConfig `mapstructure:"robotfs"` Redis RedisConfig `mapstructure:"redis"` S3 S3Config `mapstructure:"s3"` + Juicefs JuicefsConfig `mapstructure:"juicefs"` } func GetConfig() *Config { diff --git a/utils/operation.go b/utils/operation.go new file mode 100644 index 0000000..1dc4d4a --- /dev/null +++ b/utils/operation.go @@ -0,0 +1,16 @@ +package utils + +import ( + "fmt" + "os/exec" +) + +func CloneFile(src, dst string) error { + cmd := exec.Command("juicefs", "clone", src, dst) + output, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("clone failed: %v, output: %s", err, string(output)) + } + + return nil +}