aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorTom Ritter <tom@ritter.vg>2017-11-11 23:25:15 -0500
committerTom Ritter <tom@ritter.vg>2017-11-11 23:25:15 -0500
commitee3eea047c10d0032efc5a8b98d9bbdb54fe0a3a (patch)
treef7208e5c3e1107280153e6c90933f300c6113441 /main.py
parent6371a93650e74d6d4518890230eeeb5ffa7b660e (diff)
Fix executions that stomped on each other
Every hour I would fire off two executions: the minute execution and the hour execution. Each would read the statefile on start. Whichever execution took longer would overwrite the state file with the data that was present for the other's execution upon start. This would manifest as extra notifications if the starts aligned - because the 'I already sent a notification' member update wasn't being persisted. This fixes it by only performing one execution at any given time, but knowing to run all the relevant jobs for that type of execution. AKA When I run the hourly job I also run the minute jobs. Another problem related to this one is logged in #1 - minute executions that take longer than a minute will also cause this type of error.
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/main.py b/main.py
index 49bb5bb..7ee5a16 100755
--- a/main.py
+++ b/main.py
@@ -18,6 +18,22 @@ from twisted.web import server
from jobmanager import JobManager
from statustracker import StatusTracker
from servers import StatusSite, PingSite
+
+# We only run one command on the hour and day marks, but we need to execute all the jobs in that instance,
+# including our minute jobs and hour jobs
+def convert_crontimes(crontime):
+ ret = ["minute"]
+ if crontime == "minute":
+ pass
+ elif crontime == "hour":
+ ret.append("hour")
+ elif crontime == "day":
+ ret.append("hour")
+ ret.append("day")
+ elif crontime == "day_noon":
+ ret.append("hour")
+ ret.append("day_noon")
+ return ret
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Check your stuff.")
@@ -78,9 +94,9 @@ if __name__ == "__main__":
parser.print_help()
sys.exit(-1)
else:
- log.info("Running cron at frequency " + args.crontime)
+ log.info("Running cron at frequencies " + str(convert_crontimes(args.crontime)))
try:
- if jobManager.execute_jobs(args.crontime):
+ if jobManager.execute_jobs(convert_crontimes(args.crontime)):
jobManager.mark_jobs_ran()
else:
jobManager.mark_jobs_ran_with_error()