Browse Source

add benchmark host

tags/v1.21.12.1
yuyuanshifu 4 years ago
parent
commit
f850c83a40
4 changed files with 15 additions and 0 deletions
  1. +1
    -0
      custom/conf/app.ini.sample
  2. +2
    -0
      modules/setting/setting.go
  3. +11
    -0
      routers/repo/cloudbrain.go
  4. +1
    -0
      routers/routes/routes.go

+ 1
- 0
custom/conf/app.ini.sample View File

@@ -1059,6 +1059,7 @@ JOB_TYPE = debug_openi
[benchmark]
ENABLED = true
BENCHMARKCODE = https://yangzhx:justfortest123@git.openi.org.cn/yangzhx/detection_benchmark_script.git
HOST = http://192.168.202.90:3366/

[decompress]
HOST = http://192.168.207.34:39987


+ 2
- 0
modules/setting/setting.go View File

@@ -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 {


+ 11
- 0
routers/repo/cloudbrain.go View File

@@ -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)


+ 1
- 0
routers/routes/routes.go View File

@@ -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)


Loading…
Cancel
Save