30 lines
434 B
Go
30 lines
434 B
Go
package cronhu
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/robfig/cron/v3"
|
|
"go.uber.org/dig"
|
|
)
|
|
|
|
func Init(di *dig.Container) *cron.Cron {
|
|
|
|
location, err := time.LoadLocation(os.Getenv("TIMEZONE"))
|
|
|
|
if err != nil {
|
|
log.Panic("unable to load timezone!")
|
|
}
|
|
c := cron.New(cron.WithLocation(location))
|
|
err = di.Provide(func() *cron.Cron {
|
|
return c
|
|
})
|
|
|
|
if err != nil {
|
|
log.Panic("unable to initialize cron!")
|
|
}
|
|
|
|
return c
|
|
}
|