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

通过在main()方法的首行插入defer DoWhenClose()实现优雅重启 #345

Open
kiqi007 opened this issue Jul 19, 2023 · 0 comments
Open

Comments

@kiqi007
Copy link

kiqi007 commented Jul 19, 2023

细一些的通用设计就看你们了,我自己改的一版可能仅使用我们的环境。

: main方法
func main(){defer gocDoClose()

}

:goc-cover文件
import goc "example.com/simple-project/goc-cover-agent-apis-auto-generated-11111-22222-package"
func gocDoClose() {
goc.Unregister()
}

:goc文件
func Unregister(){
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
http.syncCall(ctx, "req_config")
// 完成响应才退出,http这就可以通知最后一次采集了
}

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

No branches or pull requests

1 participant