This commit is contained in:
xxj
2024-03-01 17:20:59 +08:00
parent 8a00588372
commit 6114116d01
2 changed files with 14 additions and 7 deletions

View File

@@ -9,17 +9,17 @@ var _isDev = true
var service = "service"
var fileHost = "file"
//是否开发模式
// 是否开发模式
func OnSetDev(isDev bool) {
_isDev = isDev
}
//IsDev ... 是否是开发版本
// IsDev ... 是否是开发版本
func IsDev() bool {
return _isDev
}
//判断是否在测试环境下使用
// 判断是否在测试环境下使用
func IsRunTesting() bool {
if len(os.Args) > 1 {
return strings.HasPrefix(os.Args[1], "-test")
@@ -27,22 +27,22 @@ func IsRunTesting() bool {
return false
}
//设置服务名
// 设置服务名
func SetService(s string) {
service = s
}
//获取服务名
// 获取服务名
func GetService() string {
return service
}
//设置服务名
// 设置服务名
func SetFileHost(s string) {
fileHost = s
}
//获取文件host
// 获取文件host
func GetFileHost() string {
return fileHost
}

View File

@@ -57,6 +57,13 @@ callback : 时间回调
*/
func OnPeDay(hour, min, sec int, callback func()) {
go func() {
defer func() {
defer func() {
if err := recover(); err != nil {
mylog.Error("recover OnPeDay", err)
}
}()
}()
next := tools.GetDay0(time.Now().Unix())
for {
next = time.Date(next.Year(), next.Month(), next.Day(), hour, min, sec, 0, next.Location())