I have some REST service in Gin Gonic, and I need to do some job every 5 seconds using some scheduler. I've tried rakanalh
and gocron
but it seems that every code written after initializing crons or gin routes will not execute.
func main() {
settings.AppSettings = settings.ReadSettings()
db.InitOracleDataBase()
OracleEnv, OracleSrv, OracleSes := db.GetOracleDB()
defer OracleEnv.Close()
defer OracleSrv.Close()
defer OracleSes.Close()
routes.Init()
gocron.Every(5).Seconds().Do(prOk)
<-gocron.Start()
}
prOk just prints OK, and it never will be executed, until I comment routes.init()
.
How it's possible to run both cron and gin routes concurrently?