i'm having a website that deploy on Google Cloud. The backend server has a cronjob.
func (s *server) startCronJob() error {
err := s.cron.AddFunc("CRON_TZ=Asia/Saigon 0 9 * * *", s.cronJobFunc)
if err != nil {
return err
}
s.cron.Start()
return nil
}
func (s *FBWebHookServer) sendCronProblemToSubscribedUsers() {
log.Println("Start cron job")
// DO Smt
log.Println("Done cron job")
}
The startCronJob is only run once after the deployment.
But the cron job was ran multiple time.
A 2020-03-11T02:00:00.000507Z 2020/03/11 02:00:00 Start cron job
A 2020-03-11T02:00:00.000513Z 2020/03/11 02:00:00 Start cron job
A 2020-03-11T02:00:00.000584Z 2020/03/11 02:00:00 Start cron job
A 2020-03-11T02:00:00.000663Z 2020/03/11 02:00:00 Start cron job
I guess it's because of multiple deploy. As I dig into this problem, the number of cron job runs is equal the number of deploy time (gcloud app deploy).
Is there any solution to solve this issue?
runtime: go113- Quang Lê