From 74754d545f33d5cb54abd60b1b3d375258c68a0b Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Thu, 16 Aug 2012 15:09:56 +0300 Subject: [PATCH] corrected scheduler bug --- cmd/cgr-rater/scheduler.go | 13 ++++++++----- conf/scheduler.config | 13 ++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cmd/cgr-rater/scheduler.go b/cmd/cgr-rater/scheduler.go index aa4ad4300..da62d5a5d 100644 --- a/cmd/cgr-rater/scheduler.go +++ b/cmd/cgr-rater/scheduler.go @@ -73,19 +73,22 @@ func loadActionTimings(storage timespans.StorageGetter) { sched.queue = timespans.ActionTimingPriotityList{} for key, ats := range actionTimings { toBeSaved := false - for i, at := range ats { - toBeSaved = toBeSaved || at.CheckForASAP() + isAsap := false + newAts := make([]*timespans.ActionTiming, 0) + for _, at := range ats { + isAsap = at.CheckForASAP() + toBeSaved = toBeSaved || isAsap if at.IsOneTimeRun() { timespans.Logger.Info(fmt.Sprintf("Time for one time action on %v", at)) go at.Execute() - // remove it from list - ats = append(ats[:i], ats[i+1:]...) + // do not append it to the newAts list to be saved } else { sched.queue = append(sched.queue, at) + newAts = append(newAts, at) } } if toBeSaved { - storage.SetActionTimings(key, ats) + storage.SetActionTimings(key, newAts) } } sort.Sort(sched.queue) diff --git a/conf/scheduler.config b/conf/scheduler.config index 740af2823..03c885851 100644 --- a/conf/scheduler.config +++ b/conf/scheduler.config @@ -17,18 +17,9 @@ [global] redis_server = 127.0.0.1:6379 #redis address host:port redis_db = 10 # redis database number -logdb_type = postgres # +logdb_type = mongo # logdb_host = localhost # The host to connect to. Values that start with / are for UNIX domain sockets. -logdb_port = 5432 # The port to bind to. -logdb_name = gosqltest # The name of the database to connect to. -logdb_user = rif # The user to sign in as. -logdb_passwd = testus # The user's password.root - -[rater] -enabled = true -listen = 127.0.0.1:2001 # listening address host:port, internal for internal communication only -balancer = disabled # if defined it will register to balancer as worker -rpc_encoding = gob # use JSON for RPC encoding +logdb_name = cgrates # The name of the database to connect to. [scheduler] enabled = true