r98214 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98213‎ | r98214 | r98215 >
Date:09:16, 27 September 2011
Author:ariel
Status:deferred
Tags:
Comment:
allow for self-termination via 'maintenance mode'
Modified paths:
  • /branches/ariel/xmldumps-backup/monitor.py (modified) (history)
  • /branches/ariel/xmldumps-backup/worker (modified) (history)
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -24,6 +24,26 @@
2525 from WikiDump import FileUtils, MiscUtils, TimeUtils
2626 from CommandManagement import CommandPipeline, CommandSeries, CommandsInParallel
2727
 28+class Maintenance(object):
 29+
 30+ def inMaintenanceMode():
 31+ """Use this to let callers know that we really should not
 32+ be running. Callers should try to exit the job
 33+ they are running as soon as possible."""
 34+ return exists("maintenance.txt")
 35+
 36+ def exitIfInMaintenanceMode(message = None):
 37+ """Call this from possible exit points of running jobs
 38+ in order to exit if we need to"""
 39+ if Maintenance.inMaintenanceMode():
 40+ if message:
 41+ raise BackupError(message)
 42+ else:
 43+ raise BackupError("In maintenance mode, exiting.")
 44+
 45+ inMaintenanceMode = staticmethod(inMaintenanceMode)
 46+ exitIfInMaintenanceMode = staticmethod(exitIfInMaintenanceMode)
 47+
2848 class Logger(object):
2949
3050 def __init__(self, logFileName=None):
@@ -1735,6 +1755,8 @@
17361756 # mark all the following jobs to run as well
17371757 self.dumpItemList.markFollowingJobsToRun()
17381758
 1759+ Maintenance.exitIfInMaintenanceMode("In maintenance mode, exiting dump of %s" % self.dbName )
 1760+
17391761 self.makeDir(os.path.join(self.wiki.publicDir(), self.wiki.date))
17401762 self.makeDir(os.path.join(self.wiki.privateDir(), self.wiki.date))
17411763
@@ -1752,6 +1774,8 @@
17531775
17541776 for item in self.dumpItemList.dumpItems:
17551777 if (item.toBeRun()):
 1778+ Maintenance.exitIfInMaintenanceMode("In maintenance mode, exiting dump of %s at step %s" % ( self.dbName, self.jobRequested ) )
 1779+
17561780 item.start(self)
17571781 self.status.updateStatusFiles()
17581782 self.runInfoFile.saveDumpRunInfoFile(self.dumpItemList.reportDumpRunInfo())
Index: branches/ariel/xmldumps-backup/worker
@@ -7,11 +7,16 @@
88 fi
99
1010 while true; do
11 - if [ ! -z "$configFile" ]; then
12 - python $WIKIDUMP_BASE/worker.py "--configfile" "$configFile"
 11+ if [ -e "maintenance.txt" ]; then
 12+ echo "in maintenance mode, sleeping 5 minutes"
 13+ sleep 300
1314 else
14 - python $WIKIDUMP_BASE/worker.py
 15+ if [ ! -z "$configFile" ]; then
 16+ python $WIKIDUMP_BASE/worker.py "--configfile" "$configFile"
 17+ else
 18+ python $WIKIDUMP_BASE/worker.py
 19+ fi
 20+ echo "sleeping"
 21+ sleep 30
1522 fi
16 - echo "sleeping"
17 - sleep 30
1823 done
Index: branches/ariel/xmldumps-backup/monitor.py
@@ -3,6 +3,8 @@
44 import os
55 import sys
66 import WikiDump
 7+from os.path import exists
 8+from WikiDump import FileUtils
79
810 # can specify name of alternate config file
911 if (sys.argv[1]):
@@ -32,6 +34,8 @@
3335
3436 if running:
3537 status = "Dumps are in progress..."
 38+ elif exists("maintenance.txt"):
 39+ status = FileUtils.readFile("maintenance.txt")
3640 else:
3741 status = "Dump process is idle."
3842

Status & tagging log