Index: trunk/backup/WikiDump.py |
— | — | @@ -134,6 +134,27 @@ |
135 | 135 | |
136 | 136 | self.keep = conf.getint("cleanup", "keep") |
137 | 137 | |
| 138 | + def dbListByAge(self): |
| 139 | + """Sort available wikis in reverse order of last dump.""" |
| 140 | + available = [] |
| 141 | + for db in self.dbList: |
| 142 | + wiki = Wiki(self, db) |
| 143 | + last = wiki.latestDump() |
| 144 | + if last: |
| 145 | + dumpDir = os.path.join(wiki.publicDir(), last) |
| 146 | + try: |
| 147 | + age = fileAge(dumpDir) |
| 148 | + except: |
| 149 | + print "dump dir %s vanished while looking at it!" % dumpDir |
| 150 | + available.append((sys.maxint, db)) |
| 151 | + else: |
| 152 | + position = -1 |
| 153 | + available.append((age, db)) |
| 154 | + else: |
| 155 | + available.append((sys.maxint, db)) |
| 156 | + available.sort() |
| 157 | + return [db for (age, db) in available] |
| 158 | + |
138 | 159 | def readTemplate(self, name): |
139 | 160 | template = os.path.join(self.templateDir, name) |
140 | 161 | return readFile(template) |
Index: trunk/backup/worker.py |
— | — | @@ -832,29 +832,9 @@ |
833 | 833 | return ["all-titles-in-ns0.gz"] |
834 | 834 | |
835 | 835 | |
836 | | -def findNextWikis(config): |
837 | | - """Sort available wikis in reverse order of last dump.""" |
838 | | - available = [] |
839 | | - for db in config.dbList: |
840 | | - wiki = WikiDump.Wiki(config, db) |
841 | | - if not wiki.isLocked(): |
842 | | - last = wiki.latestDump() |
843 | | - if last: |
844 | | - dumpDir = os.path.join(wiki.publicDir(), last) |
845 | | - try: |
846 | | - age = WikiDump.fileAge(dumpDir) |
847 | | - position = -1 |
848 | | - available.append((age, db)) |
849 | | - except: |
850 | | - print "dump dir %s vanished while looking at it!" % dumpDir |
851 | | - else: |
852 | | - available.append((sys.maxint, db)) |
853 | | - available.sort() |
854 | | - available.reverse() |
855 | | - return [db for (age, db) in available] |
856 | | - |
857 | 836 | def findAndLockNextWiki(config): |
858 | | - next = findNextWikis(config) |
| 837 | + next = config.dbListByAge() |
| 838 | + next.reverse() |
859 | 839 | |
860 | 840 | for x in next: |
861 | 841 | print x |
Index: trunk/backup/monitor |
— | — | @@ -7,5 +7,5 @@ |
8 | 8 | echo "Sweeping!" |
9 | 9 | python $WIKIDUMP_BASE/monitor.py |
10 | 10 | echo "sleeping" |
11 | | - sleep 30 |
| 11 | + sleep 15 |
12 | 12 | done |
Index: trunk/backup/monitor.py |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | running = False |
11 | 11 | states = [] |
12 | 12 | |
13 | | - for dbName in config.dbList: |
| 13 | + for dbName in config.dbListByAge(): |
14 | 14 | wiki = WikiDump.Wiki(config, dbName) |
15 | 15 | if wiki.isStale(): |
16 | 16 | print dbName + " is stale" |