Closed ccpwcn closed 1 year ago
I tried it a few more times and found a strange thing. If I had a bunch of cron initialization and call related code with the main package and executed it first to start gin, it would be fine, but if I put it in another package, started it and then went back to the main package to start gin, it wouldn't work. panic causes the program to exit. It's really weird.
又试了很多次,发现一个奇怪的现象,如果我的那一堆cron初始化及调用相关的代码,和main包在一起,先执行它们再去启动gin服务,是没问题,如果放在另外的一个代码包中,启动它之后回到main包中启动gin服务器,竟然就不行了,会导致panic引发程序退出。真的是太奇怪了。
排查了一段时间,不是robig/cron的问题,是我的问题,忽略这个吧。
This is my code:
this code runs ok, but, when I put it in gin server program, look like this:
in main.go, I call InitCron(), then start gin server, look like this:
When panic occurs in SchedulerTask.Run(), the entire program exits, That means cron.Recover(cl) won't work.. What is the reason for this?