Skip to content

Commit ec5c583

Browse files
committed
fix sql dir
1 parent 7b2fb2d commit ec5c583

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

app/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ func main() {
5252
}
5353
dtmimp.Logf("starting dtm....")
5454
common.MustLoadConfig()
55-
dtmcli.SetCurrentDBType(common.Config.ExamplesDB.Driver)
55+
if common.Config.ExamplesDB.Driver != "" {
56+
dtmcli.SetCurrentDBType(common.Config.ExamplesDB.Driver)
57+
}
5658
if os.Args[1] != "dtmsvr" { // 实际线上运行,只启动dtmsvr,不准备table相关的数据
5759
storage.WaitStoreUp()
5860
dtmsvr.PopulateDB(true)

common/config.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package common
22

33
import (
4+
"encoding/json"
45
"errors"
56
"io/ioutil"
67
"path/filepath"
@@ -12,9 +13,9 @@ import (
1213

1314
const (
1415
DtmMetricsPort = 8889
15-
Mysql = "mysql"
16-
Redis = "redis"
17-
BoltDb = "boltdb"
16+
Mysql = "mysql"
17+
Redis = "redis"
18+
BoltDb = "boltdb"
1819
)
1920

2021
// MicroService config type for micro service
@@ -80,11 +81,13 @@ func MustLoadConfig() {
8081
}
8182
}
8283
if len(cont) != 0 {
83-
dtmimp.Logf("config is: \n%s", string(cont))
8484
err := yaml.UnmarshalStrict(cont, &Config)
8585
dtmimp.FatalIfError(err)
8686
}
87-
err := checkConfig()
87+
scont, err := json.MarshalIndent(&Config, "", " ")
88+
dtmimp.FatalIfError(err)
89+
dtmimp.Logf("config is: \n%s", scont)
90+
err = checkConfig()
8891
dtmimp.LogIfFatalf(err != nil, `config error: '%v'.
8992
check you env, and conf.yml/conf.sample.yml in current and parent path: %s.
9093
please visit http://d.dtm.pub to see the config document.

common/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ func MustGetwd() string {
8383
func GetSqlDir() string {
8484
wd := MustGetwd()
8585
if filepath.Base(wd) == "test" {
86-
wd = filepath.Dir(wd) + "/sqls"
86+
wd = filepath.Dir(wd)
8787
}
88-
return wd
88+
return wd + "/sqls"
8989
}
9090

9191
func RecoverPanic(err *error) {

common/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestFuncs(t *testing.T) {
4343
assert.NotEqual(t, "", wd)
4444

4545
dir1 := GetSqlDir()
46-
assert.Equal(t, true, strings.HasSuffix(dir1, "common"))
46+
assert.Equal(t, true, strings.HasSuffix(dir1, "/sqls"))
4747

4848
}
4949

helper/Dockerfile-release

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" ap
1010

1111
FROM --platform=$TARGETPLATFORM alpine:3.14
1212
COPY --from=builder /app/dtm/main /app/dtm/
13-
COPY --from=builder /app/dtm/sqls/*.sql /app/dtm/sqls/
1413
ENV IS_DOCKER=1
1514
WORKDIR /app/dtm
1615
CMD ["/app/dtm/main", "dtmsvr"]

0 commit comments

Comments
 (0)