feat: reload config for the execution
This commit is contained in:
parent
ad19c98615
commit
416b478237
1 changed files with 7 additions and 5 deletions
12
main.go
12
main.go
|
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -29,10 +28,13 @@ func main() {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case t := <-cronTicker:
|
case t := <-cronTicker:
|
||||||
fmt.Println("Tick bei Sekunde 0:", t.Format(time.RFC3339Nano))
|
|
||||||
execucteJobs(t, currentConfig.Jobs)
|
execucteJobs(t, currentConfig.Jobs)
|
||||||
case t := <-configTicker:
|
case <-configTicker:
|
||||||
fmt.Println("Tick bei Sekunde 50:", t.Format(time.RFC3339Nano))
|
log.Debug().Msg("Reload Config")
|
||||||
|
currentConfig, err = ReadFromFile("config.yml")
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(err).Msg("cant read config")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +50,7 @@ func execucteJobs(t time.Time, jobs []jobconfig) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = executeCommand(job)
|
go executeCommand(job)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue