Warning: session_start(): open(/var/lib/php/sessions/sess_gqs2db1ghej7dm67dokhpbudq3, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
sclass DBWatcher {
S dbID;
RemoteDB db;
long dbDate;
long changeCount = 0;
long exportedChangeCount = 0;
*() {}
*(S *dbID) {}
bool live() { ret db != null; }
void closeDB {
if (db != null) {
db.close();
db = null;
}
}
void tryConnect {
closeDB();
pcall-short {
print("Trying to connect to " + dbID);
db = new RemoteDB(dbID);
if (db != null) print("Connected.");
}
}
void step {
bool liveBefore = live();
if (!live()) tryConnect();
if (!liveBefore && live()) changeCount = 0;
if (live() && getLiveData()) ret;
closeDB();
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) ++exportedChangeCount;
dbDate = mod;
print((change ? "CHANGE. " : "") + "DB date: " + dbDate);
true;
}
void run {
repeat with sleep 1 {
step();
}
}
}
p {
new DBWatcher(#1006463).run();
}