Skip to content

Commit

Permalink
This is an automated cherry-pick of #49843
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
lance6716 authored and ti-chi-bot committed Dec 27, 2023
1 parent 721bb1a commit ed7bc31
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
64 changes: 64 additions & 0 deletions br/cmd/br/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "br_lib",
srcs = [
"backup.go",
"cmd.go",
"debug.go",
"main.go",
"operator.go",
"restore.go",
"stream.go",
],
importpath = "github.com/pingcap/tidb/br/cmd/br",
visibility = ["//visibility:private"],
deps = [
"//br/pkg/conn",
"//br/pkg/errors",
"//br/pkg/gluetidb",
"//br/pkg/gluetikv",
"//br/pkg/logutil",
"//br/pkg/metautil",
"//br/pkg/mock/mockid",
"//br/pkg/redact",
"//br/pkg/restore",
"//br/pkg/rtree",
"//br/pkg/streamhelper/config",
"//br/pkg/summary",
"//br/pkg/task",
"//br/pkg/task/operator",
"//br/pkg/trace",
"//br/pkg/utils",
"//br/pkg/version/build",
"//pkg/config",
"//pkg/parser/model",
"//pkg/session",
"//pkg/util",
"//pkg/util/logutil",
"//pkg/util/memory",
"//pkg/util/metricsutil",
"@com_github_gogo_protobuf//proto",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_kvproto//pkg/brpb",
"@com_github_pingcap_kvproto//pkg/import_sstpb",
"@com_github_pingcap_log//:log",
"@com_github_spf13_cobra//:cobra",
"@com_sourcegraph_sourcegraph_appdash//:appdash",
"@org_uber_go_zap//:zap",
],
)

go_binary(
name = "br",
embed = [":br_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "br_test",
timeout = "short",
srcs = ["main_test.go"],
embed = [":br_lib"],
flaky = True,
)
8 changes: 8 additions & 0 deletions br/cmd/br/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ import (
"github.com/pingcap/tidb/br/pkg/task"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/br/pkg/version/build"
<<<<<<< HEAD
"github.com/pingcap/tidb/util/logutil"
=======
"github.com/pingcap/tidb/pkg/config"
tidbutils "github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/memory"
>>>>>>> d0d24aeef42 (br, lightning: call memory hook init in main() (#49843))
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -151,6 +158,7 @@ func Init(cmd *cobra.Command) (err error) {
return
}
log.ReplaceGlobals(lg, p)
memory.InitMemoryHook()

redactLog, e := cmd.Flags().GetBool(FlagRedactLog)
if e != nil {
Expand Down
31 changes: 31 additions & 0 deletions br/cmd/tidb-lightning/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "tidb-lightning_lib",
srcs = ["main.go"],
importpath = "github.com/pingcap/tidb/br/cmd/tidb-lightning",
visibility = ["//visibility:private"],
deps = [
"//br/pkg/lightning",
"//br/pkg/lightning/common",
"//br/pkg/lightning/config",
"//br/pkg/lightning/log",
"//br/pkg/lightning/web",
"//pkg/util/memory",
"@org_uber_go_zap//:zap",
],
)

go_binary(
name = "tidb-lightning",
embed = [":tidb-lightning_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "tidb-lightning_test",
timeout = "short",
srcs = ["main_test.go"],
embed = [":tidb-lightning_lib"],
flaky = True,
)
6 changes: 6 additions & 0 deletions br/cmd/tidb-lightning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import (
"github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
<<<<<<< HEAD
=======
"github.com/pingcap/tidb/br/pkg/lightning/web"
"github.com/pingcap/tidb/pkg/util/memory"
>>>>>>> d0d24aeef42 (br, lightning: call memory hook init in main() (#49843))
"go.uber.org/zap"
)

Expand All @@ -37,6 +42,7 @@ func main() {
}

app := lightning.New(globalCfg)
memory.InitMemoryHook()

sc := make(chan os.Signal, 1)
signal.Notify(sc,
Expand Down

0 comments on commit ed7bc31

Please sign in to comment.