Permalink
Browse files

Create revision checker agent for the first

  • Loading branch information...
1 parent b31b1a9 commit 52c2ebc2f78d354e9ce029685dd942d32d1d0796 @kachayev committed Aug 7, 2011
Showing with 13 additions and 3 deletions.
  1. +9 −3 gearoscope/apps/monitor/agents/reloader.py
  2. +4 −0 gearoscope/apps/monitor/sonard.py
@@ -10,13 +10,19 @@ class RevisionCheckerAgent(object):
agent will be stoped in soft mode and sonar object will be
rebuild with using new database configuration
'''
+ # Initial revision ID
revision = None
- def __init__(self):
- self.revision = Revision.last.get()
+ # Manager for working with revision objects
+ manager = None
+
+ def __init__(self, manager=None):
+ '''Initialize manager object and retriew current revision ID'''
+ self.manager = manager
+ self.revision = manager.get()['id']
def work(self):
'''Check last revision ID, if not equals reload sonar'''
- Revision.last.get()['id'] != self.revision['id']:
+ self.manager.get()['id'] != self.revision:
Sonar.stop()
@@ -40,6 +40,10 @@ def make(options):
# Create sonar object
s = loop.Sonar(options)
+ # For the first, we should initialize revision check agent,
+ # which will "remember" current database revision ID
+ s.add_agent(RevisionCheckerAgent(manager=Revision.last))
+
# Create server pool with using information stored in database
for server in scoper.models.Server.objects.all():
ServerPool.add(Server(**server.__dict__))

0 comments on commit 52c2ebc

Please sign in to comment.