separate frontend repository

This commit is contained in:
Alireza Ahmadi
2025-01-28 23:57:53 +01:00
parent f4b1b09362
commit 7faa28a89d
194 changed files with 48 additions and 19256 deletions
+39
View File
@@ -0,0 +1,39 @@
package cronjob
import (
"time"
"github.com/robfig/cron/v3"
)
type CronJob struct {
cron *cron.Cron
}
func NewCronJob() *CronJob {
return &CronJob{}
}
func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
c.cron = cron.New(cron.WithLocation(loc), cron.WithSeconds())
c.cron.Start()
go func() {
// Start stats job
c.cron.AddJob("@every 10s", NewStatsJob())
// Start expiry job
c.cron.AddJob("@every 1m", NewDepleteJob())
// Start deleting old stats
c.cron.AddJob("@daily", NewDelStatsJob(trafficAge))
// Start core if it is not running
c.cron.AddJob("@every 5s", NewCheckCoreJob())
}()
return nil
}
func (c *CronJob) Stop() {
if c.cron != nil {
c.cron.Stop()
}
}