Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jobbase.go 中的 Setup 调用一次 setup 就会停止了, 是设计成这样吗 #778

Open
xpoy1 opened this issue Nov 14, 2023 · 1 comment
Labels

Comments

@xpoy1
Copy link

xpoy1 commented Nov 14, 2023

Reproduction link

https://github.com/go-admin-team/go-admin/blob/master/app/jobs/jobbase.go

Steps to reproduce

// Setup 初始化
func Setup(dbs map[string]*gorm.DB) {

	fmt.Println(time.Now().Format(timeFormat), " [INFO] JobCore Starting...")

	for k, db := range dbs {
		sdk.Runtime.SetCrontab(k, cronjob.NewWithSeconds())
		setup(k, db)
	}
}


func setup(key string, db *gorm.DB) {
	crontab := sdk.Runtime.GetCrontabKey(key)
	//....

	// 其中任务
	crontab.Start()
	fmt.Println(time.Now().Format(timeFormat), " [INFO] JobCore start success.")
	// 关闭任务
	defer crontab.Stop()
	select {}
}

What is expected?

for k, db := range dbs { 

是想对每个 db 循环执行setup?

What is actually happening?

setup 中 select {} 永久阻塞, 不会返回了

Environment Info
go-admin undefined
Go go
System any
Browser any
@wenjianzhang
Copy link
Member

这里是针对多租户添加的初始化db

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants