From cb526ff563655fa04a423ed3ed45eeca2805dfe6 Mon Sep 17 00:00:00 2001 From: yuyuanshifu <747342561@qq.com> Date: Thu, 7 Jan 2021 17:27:13 +0800 Subject: [PATCH] add benchmark host --- modules/setting/setting.go | 2 ++ routers/repo/cloudbrain.go | 11 +++++++++++ routers/routes/routes.go | 1 + 3 files changed, 14 insertions(+) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index c38764088..a71617e8d 100755 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -442,6 +442,7 @@ var ( //benchmark config IsBenchmarkEnabled bool BenchmarkCode string + BenchmarkServerHost string ) // DateLang transforms standard language locale name to corresponding value in datetime plugin. @@ -1121,6 +1122,7 @@ func NewContext() { sec = Cfg.Section("benchmark") IsBenchmarkEnabled = sec.Key("ENABLED").MustBool(false) BenchmarkCode = sec.Key("BENCHMARKCODE").MustString("https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git") + BenchmarkServerHost = sec.Key("HOST").MustString("http://192.168.202.90:3366/") } func loadInternalToken(sec *ini.Section) string { diff --git a/routers/repo/cloudbrain.go b/routers/repo/cloudbrain.go index 8b1e3c384..98c6457e4 100755 --- a/routers/repo/cloudbrain.go +++ b/routers/repo/cloudbrain.go @@ -280,6 +280,17 @@ func CloudBrainDel(ctx *context.Context) { ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/cloudbrain") } +func CloudBrainBenchmark(ctx *context.Context) { + var jobID = ctx.Params(":jobid") + _, err := models.GetCloudbrainByJobID(jobID) + if err != nil { + ctx.ServerError("GetCloudbrainByJobID failed", err) + return + } + + ctx.Redirect(setting.BenchmarkServerHost) +} + func downloadCode(repo *models.Repository, codePath string) error { if err := git.Clone(repo.RepoPath(), codePath, git.CloneRepoOptions{}); err != nil { log.Error("Failed to clone repository: %s (%v)", repo.FullName(), err) diff --git a/routers/routes/routes.go b/routers/routes/routes.go index c7f969e76..790650a2d 100755 --- a/routers/routes/routes.go +++ b/routers/routes/routes.go @@ -900,6 +900,7 @@ func RegisterRoutes(m *macaron.Macaron) { m.Post("/commit_image", reqRepoCloudBrainWriter, bindIgnErr(auth.CommitImageCloudBrainForm{}), repo.CloudBrainCommitImage) m.Post("/stop", reqRepoCloudBrainWriter, repo.CloudBrainStop) m.Post("/del", reqRepoCloudBrainWriter, repo.CloudBrainDel) + m.Post("/benchmark", reqRepoCloudBrainWriter, repo.CloudBrainBenchmark) }) m.Get("/create", reqRepoCloudBrainWriter, repo.CloudBrainNew) m.Post("/create", reqRepoCloudBrainWriter, bindIgnErr(auth.CreateCloudBrainForm{}), repo.CloudBrainCreate)