Index: branches/ariel/xmldumps-backup/worker.py |
— | — | @@ -24,6 +24,26 @@ |
25 | 25 | from WikiDump import FileUtils, MiscUtils, TimeUtils |
26 | 26 | from CommandManagement import CommandPipeline, CommandSeries, CommandsInParallel |
27 | 27 | |
| 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 | + |
28 | 48 | class Logger(object): |
29 | 49 | |
30 | 50 | def __init__(self, logFileName=None): |
— | — | @@ -1735,6 +1755,8 @@ |
1736 | 1756 | # mark all the following jobs to run as well |
1737 | 1757 | self.dumpItemList.markFollowingJobsToRun() |
1738 | 1758 | |
| 1759 | + Maintenance.exitIfInMaintenanceMode("In maintenance mode, exiting dump of %s" % self.dbName ) |
| 1760 | + |
1739 | 1761 | self.makeDir(os.path.join(self.wiki.publicDir(), self.wiki.date)) |
1740 | 1762 | self.makeDir(os.path.join(self.wiki.privateDir(), self.wiki.date)) |
1741 | 1763 | |
— | — | @@ -1752,6 +1774,8 @@ |
1753 | 1775 | |
1754 | 1776 | for item in self.dumpItemList.dumpItems: |
1755 | 1777 | if (item.toBeRun()): |
| 1778 | + Maintenance.exitIfInMaintenanceMode("In maintenance mode, exiting dump of %s at step %s" % ( self.dbName, self.jobRequested ) ) |
| 1779 | + |
1756 | 1780 | item.start(self) |
1757 | 1781 | self.status.updateStatusFiles() |
1758 | 1782 | self.runInfoFile.saveDumpRunInfoFile(self.dumpItemList.reportDumpRunInfo()) |
Index: branches/ariel/xmldumps-backup/worker |
— | — | @@ -7,11 +7,16 @@ |
8 | 8 | fi |
9 | 9 | |
10 | 10 | 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 |
13 | 14 | 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 |
15 | 22 | fi |
16 | | - echo "sleeping" |
17 | | - sleep 30 |
18 | 23 | done |
Index: branches/ariel/xmldumps-backup/monitor.py |
— | — | @@ -3,6 +3,8 @@ |
4 | 4 | import os |
5 | 5 | import sys |
6 | 6 | import WikiDump |
| 7 | +from os.path import exists |
| 8 | +from WikiDump import FileUtils |
7 | 9 | |
8 | 10 | # can specify name of alternate config file |
9 | 11 | if (sys.argv[1]): |
— | — | @@ -32,6 +34,8 @@ |
33 | 35 | |
34 | 36 | if running: |
35 | 37 | status = "Dumps are in progress..." |
| 38 | + elif exists("maintenance.txt"): |
| 39 | + status = FileUtils.readFile("maintenance.txt") |
36 | 40 | else: |
37 | 41 | status = "Dump process is idle." |
38 | 42 | |