!7 sclass DBWatcher { S dbID; RemoteDB db; long dbDate; long changeCount = 0; long exportedChangeCount = 0; *() {} *(S *dbID) {} bool live() { ret db != null; } void tryConnect { db = connectToDBOpt(dbID); } void step { bool liveBefore = live(); if (!live()) tryConnect(); if (!liveBefore && live()) changeCount = 0; if (live() && getLiveData()) ret; getStaticData(); } bool getLiveData() false on exception { time2 { long cc = db.xchangeCount(); int n = db.xcount(); } bool change = cc != changeCount; if (change) ++exportedChangeCount; changeCount = cc; print((change ? "CHANGE. " : "") + "Live change count: " + cc + ", objects: " + n); true; } bool getStaticData() false on exception { File conceptsFile = getFilePossiblyGZipped(getProgramFile(dbID, "concepts.structure")); long mod = conceptsFile.lastModified(); bool change = mod != dbDate; if (change) dbDate = mod; print((change ? "CHANGE. " : "") + "DB date: " + dbDate); } void run { repeat with sleep 1 { step(); } } } p { new DBWatcher(#1006463).run(); }