summaryrefslogtreecommitdiff
path: root/lorry-controller
diff options
context:
space:
mode:
Diffstat (limited to 'lorry-controller')
-rwxr-xr-xlorry-controller19
1 files changed, 19 insertions, 0 deletions
diff --git a/lorry-controller b/lorry-controller
index e3f7d36..b3c2c45 100755
--- a/lorry-controller
+++ b/lorry-controller
@@ -12,6 +12,7 @@ import re
from lorrycontroller.confparser import LorryControllerConfig
from lorrycontroller.workingstate import WorkingStateManager
+from lorrycontroller.htmlstatus import HTMLStatusManager
defaults = {
@@ -51,6 +52,10 @@ class LorryController(cliapp.Application):
'Log file name for lorry if wanted',
metavar='LORRYLOG',
default=None)
+ self.settings.string(['html-file'],
+ 'HTML filename for lorry controller status',
+ metavar='HTMLFILE',
+ default=None)
def process_args(self, args):
logging.info("Starting to control lorry")
@@ -83,9 +88,16 @@ class LorryController(cliapp.Application):
raise SystemExit(4)
self.conf = LorryControllerConfig(self, 'git/lorry-controller.conf')
+ self.html = HTMLStatusManager(self)
+ if self.settings['dry-run']:
+ self.html.series = 0
+ self.html.write_out_status()
+ self.conf.parse_config()
with WorkingStateManager(self) as mgr:
# Update any troves
+ self.html.set_mgr(mgr)
+ self.html.bump_state()
self.conf.update_troves(mgr)
prev_lorries = set(mgr.lorry_state.keys())
cur_lorries = set(self.conf.lorries.keys())
@@ -94,8 +106,10 @@ class LorryController(cliapp.Application):
len(prev_lorries), len(cur_lorries)))
# 1. Handle deletes for any old lorries we no longer want
+ self.html.bump_state()
logging.info("Delete any old lorries...")
for dead_lorry in prev_lorries - cur_lorries:
+ self.html.set_processing(dead_lorry)
logging.info("Dead lorry: %s" % dead_lorry)
conf_uuid = mgr.lorry_state[dead_lorry]['conf']
if conf_uuid in self.conf.configs:
@@ -134,8 +148,10 @@ class LorryController(cliapp.Application):
del mgr.lorry_state[dead_lorry]
# 2. Handle creates for any new lorries we now want
+ self.html.bump_state()
logging.info("Create any new lorries...")
for new_lorry in cur_lorries - prev_lorries:
+ self.html.set_processing(new_lorry)
logging.info("New lorry: %s" % new_lorry)
lorry = self.conf.lorries[new_lorry]
conf_uuid = lorry['controller-uuid']
@@ -170,6 +186,7 @@ class LorryController(cliapp.Application):
# 3. For every lorry we have, update the settings if necessary.
# and reset the next-due as appropriate.
+ self.html.bump_state()
logging.info("Update active lorry configurations...")
updated_count = 0
for upd_lorry in cur_lorries:
@@ -217,6 +234,7 @@ class LorryController(cliapp.Application):
lorried += 1
logging.info("Running %d/%d. Lorrying: %s" % (
lorried, len(lorries_to_run),lorry))
+ self.html.set_processing(lorry)
with mgr.runner(lorry) as runner:
runner.run_lorry(*self.lorrycmd)
while state['next-due'] <= now:
@@ -235,6 +253,7 @@ class LorryController(cliapp.Application):
logging.info("Lorried %d. %s due in %d seconds" % (
lorried, what_early_due, int(earliest_due - now)))
logging.info("All done.")
+ self.html.bump_state()
def rungit(self, args):
self.runcmd(['git']+args, cwd=os.path.join(self.settings['work-area'],