作者 郑周

1. 根据环境变量 设置定时时间

... ... @@ -60,6 +60,8 @@ spec:
value: "debug"
- name: LOG_FILE
value: "true"
- name: ENV_MOD
value: "prd"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
... ...
... ... @@ -60,6 +60,8 @@ spec:
value: "debug"
- name: LOG_FILE
value: "true"
- name: ENV_MOD
value: "test"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
... ...
package main
import (
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
"time"
"github.com/beego/beego/v2/server/web"
... ... @@ -27,7 +28,13 @@ func startNodeTask() {
go func() {
nodeTaskService := serviceTask.NewNodeTaskService()
for {
timer := time.NewTimer(time.Minute * 5)
var duration time.Duration
if constant.Env == "prd" {
duration = time.Minute * 5
} else {
duration = time.Minute * 1
}
timer := time.NewTimer(duration)
<-timer.C
if err := nodeTaskService.SendEvaluationNode(); err != nil {
log.Logger.Error(err.Error())
... ...
... ... @@ -11,8 +11,15 @@ var AdminJwtExpiresIn = int64(3600 * 24 * 7)
var AdminJWTSecretKey = "sg-storage"
// Env 判断当前环境变量
var Env = "dev"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
}
if os.Getenv("ENV_MOD") != "" {
Env = os.Getenv("ENV_MOD")
}
}
... ...