Compare commits

...

6 Commits

Author SHA1 Message Date
liaoyulong
ba0f9bfd98 新增通用方法 2025-10-27 18:20:26 +08:00
ayflying
d07881bc29 上传失败后,尝试使用自己的代理地址 2025-10-27 16:12:11 +08:00
cdcdac3531 测试代码 更新 2025-10-20 15:10:43 +08:00
0a19bb5518 Merge branch 'master' of new-gitlab.adesk.com:public_project/utility_go 2025-10-20 14:50:27 +08:00
c7409fbf02 注释更新 2025-10-20 14:50:26 +08:00
ayflying
82d3824cae 更新服务器代码通过判断本地配置文件决定需要更新的目录 2025-10-20 10:14:19 +08:00
3 changed files with 28 additions and 5 deletions

View File

@@ -42,6 +42,9 @@ var (
getFileName, err := g.Cfg("hack").Get(ctx, "gfcli.build.name")
Filename := getFileName.String()
getPath, err := g.Cfg("hack").Get(ctx, "gfcli.build.path")
Path := getPath.String()
//获取版本号
getVersion, err := g.Cfg("hack").Get(ctx, "gfcli.build.version")
Version := getVersion.String()
@@ -89,7 +92,7 @@ var (
if v.Arch != "" && v.System != "" {
systemName = v.System + "_" + v.Arch
}
var filename = path.Join(Version, systemName, Filename)
var filename = path.Join(Path, Version, systemName, Filename)
g.Log().Debugf(ctx, "当前上传文件:"+filename)
url[v.S3], err = UploadS3(v.S3, filename)
@@ -109,9 +112,24 @@ var (
FileUrl: url[v.S3],
})
if err != nil {
Proxy := g.Cfg().MustGet(ctx, "update_proxy", "http://192.168.50.170:10808").String()
g.Log().Debugf(ctx, "切换代理进行上传:err=%v", err)
get, err = client.Proxy(Proxy).Post(ctx, address+"/callback/update", &UpdateReq{
// 读取HTTP代理环境变量小写/大写通常都兼容,部分系统可能用大写)
httpProxy := os.Getenv("http_proxy")
if httpProxy == "" {
httpProxy = os.Getenv("HTTP_PROXY")
}
if httpProxy == "" {
// 读取HTTPS代理环境变量
httpProxy = os.Getenv("https_proxy")
if httpProxy == "" {
httpProxy = os.Getenv("HTTPS_PROXY")
}
}
// 如果没有读取到本地的代理,使用配置上传
if httpProxy == "" {
httpProxy = g.Cfg().MustGet(ctx, "update_proxy", "http://192.168.50.173:10808").String()
}
g.Log().Debugf(ctx, "切换代理进行上传:ip=%v,err=%v", httpProxy, err)
get, err = client.Proxy(httpProxy).Post(ctx, address+"/callback/update", &UpdateReq{
FileUrl: url[v.S3],
})
}

View File

@@ -23,7 +23,7 @@ func TestGamelog(t *testing.T) {
// 可填
RetryN: 2, // 默认每10次, 上传检查一次磁盘的失败数据
ChanSize: 500, // 默认1000, 信道size
SendSaveType: 1, // 发送存储类型, 默认不设置为0代表文件存储, 1代表走kafka可实同步日志
SendSaveType: 2, // 发送存储类型, 默认不设置为0代表文件存储, 2代表走kafka可实同步日志
})
// 随机测试事件和属性

View File

@@ -152,3 +152,8 @@ func (m *timeMod) CheckIsBeRwd(createdTime, lastRwdTime time.Time, _now ...time.
// 如果是,则说明还没领过,可以领取
return lastRwdTime.Before(refreshToday)
}
// 获取指定时间的本月最后一刻
func (m *timeMod) EndOfMonth(t time.Time) time.Time {
return time.Date(t.Year(), t.Month()+1, 1, 0, 0, 0, 0, t.Location()).Add(-time.Second)
}