mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
started scheduler
This commit is contained in:
@@ -70,6 +70,7 @@ var (
|
||||
|
||||
bal = balancer.NewBalancer()
|
||||
accLock = timespans.NewAccountLock()
|
||||
getter timespans.StorageGetter
|
||||
exitChan = make(chan bool)
|
||||
)
|
||||
|
||||
@@ -120,7 +121,9 @@ func listenToRPCRequests(responder interface{}, rpcAddress string, json bool) {
|
||||
defer l.Close()
|
||||
|
||||
if err != nil {
|
||||
timespans.Logger.Err(fmt.Sprintf("could not connect to rpc server: %v", err))
|
||||
timespans.Logger.Err(fmt.Sprintf("could start the rpc server: %v", err))
|
||||
exitChan <- true
|
||||
return
|
||||
}
|
||||
|
||||
timespans.Logger.Info(fmt.Sprintf("Listening for incomming RPC requests on %v", l.Addr()))
|
||||
@@ -183,7 +186,7 @@ func main() {
|
||||
|
||||
if scheduler_enabled {
|
||||
go func() {
|
||||
loadActionTimings()
|
||||
loadActionTimings(getter)
|
||||
go reloadSchedulerSingnalHandler()
|
||||
s.loop()
|
||||
}()
|
||||
|
||||
@@ -139,7 +139,7 @@ func reloadSchedulerSingnalHandler() {
|
||||
sig := <-c
|
||||
|
||||
timespans.Logger.Info(fmt.Sprintf("Caught signal %v, reloading action timings.\n", sig))
|
||||
loadActionTimings()
|
||||
loadActionTimings(getter)
|
||||
// check the tip of the queue for new actions
|
||||
restartLoop <- 1
|
||||
timer.Stop()
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
storage timespans.StorageGetter
|
||||
timer *time.Timer
|
||||
restartLoop = make(chan byte)
|
||||
s = scheduler{}
|
||||
@@ -63,15 +62,7 @@ func (s scheduler) loop() {
|
||||
}
|
||||
}
|
||||
|
||||
func reloadActionTimings() {
|
||||
log.Print("Reloading action timings.")
|
||||
loadActionTimings()
|
||||
// check the tip of the queue for new actions
|
||||
restartLoop <- 1
|
||||
timer.Stop()
|
||||
}
|
||||
|
||||
func loadActionTimings() {
|
||||
func loadActionTimings(storage timespans.StorageGetter) {
|
||||
actionTimings, err := storage.GetAllActionTimings()
|
||||
if err != nil {
|
||||
log.Fatalf("Cannot get action timings:", err)
|
||||
|
||||
Reference in New Issue
Block a user