add some new files and services add hwtools that shows the current and last GWs - not yet included the user stats (if any available)
39 lines
807 B
Go
39 lines
807 B
Go
package services
|
|
|
|
import (
|
|
"hwcollector/server/services/cronjob"
|
|
"hwcollector/server/services/datacollector"
|
|
"hwcollector/server/services/datapreprocessor"
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/robfig/cron/v3"
|
|
)
|
|
|
|
// Services all Services
|
|
type Services struct {
|
|
DataPreProcessing *datapreprocessor.PreProcessor
|
|
CronJob *cron.Cron
|
|
DataCollector func()
|
|
}
|
|
|
|
// MainServices Get all Services
|
|
func MainServices(debug bool) *Services {
|
|
cj := cronjob.InitCron(debug)
|
|
services := new(Services)
|
|
services.CronJob = cj
|
|
|
|
dir, err := os.Getwd()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
path, err := filepath.Abs(dir)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
services.DataPreProcessing = datapreprocessor.NewPreProcessor(path, debug)
|
|
services.DataCollector = datacollector.Start
|
|
return services
|
|
}
|