add sample cron file and fix scheduler

master
bel 2020-03-13 05:06:03 +00:00
parent 2db4fc7176
commit 2efb0bfcf3
3 changed files with 24 additions and 15 deletions

11
main.go
View File

@ -3,10 +3,8 @@ package main
import (
"local/firestormy/config"
"local/firestormy/scheduler"
"local/firestormy/server"
"local/lastn/lastn"
"log"
"net/http"
"os"
"os/signal"
"path/filepath"
@ -17,14 +15,18 @@ func main() {
var err error
s := scheduler.New()
if config.Config != "" {
var err error
s, err = scheduler.NewFromFile(config.Config)
} else {
err = s.Start()
if err != nil {
panic(err)
}
}
err = s.Start()
if err != nil {
panic(err)
}
/*
server := server.New()
if err := server.Routes(); err != nil {
panic(err)
@ -38,6 +40,7 @@ func main() {
panic(err)
}
}()
*/
// catch stop
stop := make(chan os.Signal)

View File

@ -102,6 +102,11 @@ func (s *Scheduler) Start() error {
}
}
s.cron.Start()
entries := s.cron.Entries()
logger.New().Info("started", len(entries), "jobs")
for _, entry := range entries {
logger.New().Info(fmt.Sprintf("%+v", entry))
}
return nil
}

1
testdata/hostname_per_second.cron vendored Normal file
View File

@ -0,0 +1 @@
* * * * * * hostname