integrate core codes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package cronjob
|
||||
|
||||
import (
|
||||
"s-ui/core"
|
||||
"time"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
@@ -8,10 +9,13 @@ import (
|
||||
|
||||
type CronJob struct {
|
||||
cron *cron.Cron
|
||||
Core *core.Core
|
||||
}
|
||||
|
||||
func NewCronJob() *CronJob {
|
||||
return &CronJob{}
|
||||
func NewCronJob(c *core.Core) *CronJob {
|
||||
return &CronJob{
|
||||
Core: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CronJob) Start(loc *time.Location, trafficAge int) error {
|
||||
|
||||
@@ -6,15 +6,15 @@ import (
|
||||
)
|
||||
|
||||
type StatsJob struct {
|
||||
service.SingBoxService
|
||||
service.StatsService
|
||||
}
|
||||
|
||||
func NewStatsJob() *StatsJob {
|
||||
return new(StatsJob)
|
||||
return &StatsJob{}
|
||||
}
|
||||
|
||||
func (s *StatsJob) Run() {
|
||||
err := s.SingBoxService.GetStats()
|
||||
err := s.StatsService.SaveStats()
|
||||
if err != nil {
|
||||
logger.Warning("Get stats failed: ", err)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user