r20742 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r20741‎ | r20742 | r20743 >
Date:17:54, 27 March 2007
Author:brion
Status:old
Tags:
Comment:
* show monitor list in most-recently-dumped order so the action is on top
* run monitor updates more frequently
Modified paths:
  • /trunk/backup/WikiDump.py (modified) (history)
  • /trunk/backup/monitor (modified) (history)
  • /trunk/backup/monitor.py (modified) (history)
  • /trunk/backup/worker.py (modified) (history)

Diff [purge]

Index: trunk/backup/WikiDump.py
@@ -134,6 +134,27 @@
135135
136136 self.keep = conf.getint("cleanup", "keep")
137137
 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+
138159 def readTemplate(self, name):
139160 template = os.path.join(self.templateDir, name)
140161 return readFile(template)
Index: trunk/backup/worker.py
@@ -832,29 +832,9 @@
833833 return ["all-titles-in-ns0.gz"]
834834
835835
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 -
857836 def findAndLockNextWiki(config):
858 - next = findNextWikis(config)
 837+ next = config.dbListByAge()
 838+ next.reverse()
859839
860840 for x in next:
861841 print x
Index: trunk/backup/monitor
@@ -7,5 +7,5 @@
88 echo "Sweeping!"
99 python $WIKIDUMP_BASE/monitor.py
1010 echo "sleeping"
11 - sleep 30
 11+ sleep 15
1212 done
Index: trunk/backup/monitor.py
@@ -9,7 +9,7 @@
1010 running = False
1111 states = []
1212
13 - for dbName in config.dbList:
 13+ for dbName in config.dbListByAge():
1414 wiki = WikiDump.Wiki(config, dbName)
1515 if wiki.isStale():
1616 print dbName + " is stale"