started scheduler

This commit is contained in:
Radu Ioan Fericean
2012-07-21 18:05:32 +03:00
parent 3c47bcfbe7
commit 6d7d340cb2
3 changed files with 7 additions and 13 deletions

View File

@@ -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()
}()

View File

@@ -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()

View File

@@ -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)