diff --git a/server/bin/marketing-data-server b/server/bin/marketing-data-server new file mode 100755 index 0000000..8790ef3 Binary files /dev/null and b/server/bin/marketing-data-server differ diff --git a/server/internal/config/config.go b/server/internal/config/config.go index fee9e84..05818fd 100644 --- a/server/internal/config/config.go +++ b/server/internal/config/config.go @@ -101,3 +101,38 @@ func (d DB) DSN() string { } return d.User + ":" + d.Password + "@tcp(" + d.Host + ":" + d.Port + ")/" + d.Name + "?parseTime=True&loc=Local&charset=utf8mb4" } + +func LoadEnv() { + paths := []string{ + ".env.local", + filepath.Join("server", ".env.local"), + } + for _, p := range paths { + f, err := os.Open(p) + if err != nil { + continue + } + b, err := io.ReadAll(f) + f.Close() + if err != nil { + continue + } + lines := strings.Split(string(b), "\n") + for _, ln := range lines { + s := strings.TrimSpace(ln) + if s == "" || strings.HasPrefix(s, "#") { + continue + } + kv := strings.SplitN(s, "=", 2) + if len(kv) != 2 { + continue + } + k := strings.TrimSpace(kv[0]) + v := strings.TrimSpace(kv[1]) + if k != "" { + os.Setenv(k, v) + } + } + break + } +} diff --git a/server/log/server-20251127.log b/server/log/server-20251127.log index 60e8abe..4934ca5 100644 --- a/server/log/server-20251127.log +++ b/server/log/server-20251127.log @@ -138,3 +138,5 @@ server listening on :8077 {"bytes":2075,"duration_ms":44,"kind":"access","level":"INFO","method":"","path":"","query":"","remote":"","status":200,"trace_id":"","ts":"2025-11-27T18:38:02+08:00"} {"bytes":2075,"duration_ms":47,"kind":"access","level":"INFO","method":"","path":"","query":"","remote":"","status":200,"trace_id":"","ts":"2025-11-27T18:38:04+08:00"} {"bytes":2187,"duration_ms":92,"kind":"access","level":"INFO","method":"","path":"","query":"","remote":"","status":200,"trace_id":"","ts":"2025-11-27T18:38:10+08:00"} +connecting YMT MySQL: 47.97.27.195:3306 db merketing user root +connecting Marketing MySQL: 192.168.6.92:3306 db market user root