all adjustments

This commit is contained in:
Alireza Ahmadi
2025-01-03 23:32:03 +01:00
parent ed48cdca33
commit fe428ed412
62 changed files with 2352 additions and 1975 deletions
+4 -6
View File
@@ -1,7 +1,6 @@
package cronjob
import (
"s-ui/core"
"time"
"github.com/robfig/cron/v3"
@@ -9,13 +8,10 @@ import (
type CronJob struct {
cron *cron.Cron
Core *core.Core
}
func NewCronJob(c *core.Core) *CronJob {
return &CronJob{
Core: c,
}
func NewCronJob() *CronJob {
return &CronJob{}
}
func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
@@ -29,6 +25,8 @@ func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
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