Index: branches/ariel/xmldumps-backup/worker.py |
— | — | @@ -1832,6 +1832,12 @@ |
1833 | 1833 | |
1834 | 1834 | self.showRunnerStateComplete() |
1835 | 1835 | |
| 1836 | + # let caller know if this was a successful run |
| 1837 | + if self.status.failCount > 0: |
| 1838 | + return False |
| 1839 | + else: |
| 1840 | + return True |
| 1841 | + |
1836 | 1842 | def cleanOldDumps(self): |
1837 | 1843 | if self._cleanOldDumpsEnabled: |
1838 | 1844 | old = self.wiki.dumpDirs() |
— | — | @@ -3706,6 +3712,7 @@ |
3707 | 3713 | chunkToDo = False |
3708 | 3714 | checkpointFile = None |
3709 | 3715 | pageIDRange = None |
| 3716 | + result = False |
3710 | 3717 | |
3711 | 3718 | try: |
3712 | 3719 | (options, remainder) = getopt.gnu_getopt(sys.argv[1:], "", |
— | — | @@ -3806,11 +3813,16 @@ |
3807 | 3814 | print "Running %s, job %s..." % (wiki.dbName, jobRequested) |
3808 | 3815 | else: |
3809 | 3816 | print "Running %s..." % wiki.dbName |
3810 | | - runner.run() |
| 3817 | + result = runner.run() |
3811 | 3818 | # if we are doing one piece only of the dump, we don't unlock either |
3812 | 3819 | if locksEnabled: |
3813 | 3820 | wiki.unlock() |
3814 | 3821 | else: |
3815 | 3822 | print "No wikis available to run." |
| 3823 | + result = True |
3816 | 3824 | finally: |
3817 | 3825 | WikiDump.cleanup() |
| 3826 | + if result == False: |
| 3827 | + sys.exit(1) |
| 3828 | + else: |
| 3829 | + sys.exit(0) |
Index: branches/ariel/xmldumps-backup/worker |
— | — | @@ -1,5 +1,10 @@ |
2 | 2 | #!/bin/bash |
3 | 3 | |
| 4 | +# number of failures of worker.py in a row before we decide |
| 5 | +# something serious is broken and we refuse to run |
| 6 | +MAXFAILS=3 |
| 7 | +failures=0 |
| 8 | + |
4 | 9 | WIKIDUMP_BASE=`dirname "$0"` |
5 | 10 | |
6 | 11 | if [ ! -z "$1" ]; then |
— | — | @@ -7,7 +12,7 @@ |
8 | 13 | fi |
9 | 14 | |
10 | 15 | while true; do |
11 | | - if [ -e "maintenance.txt" ]; then |
| 16 | + if [ -e "$WIKIDUMP_BASE/maintenance.txt" ]; then |
12 | 17 | echo "in maintenance mode, sleeping 5 minutes" |
13 | 18 | sleep 300 |
14 | 19 | else |
— | — | @@ -16,6 +21,13 @@ |
17 | 22 | else |
18 | 23 | python $WIKIDUMP_BASE/worker.py |
19 | 24 | fi |
| 25 | + if [ $? -ne 0 ]; then |
| 26 | + failures=$(($failures+1)) |
| 27 | + if [ $failures -gt $MAXFAILS ]; then |
| 28 | + echo "more than $MAXFAILS failures in a row, halting." |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + fi |
20 | 32 | echo "sleeping" |
21 | 33 | sleep 30 |
22 | 34 | fi |