2018-08-13 Fred Gleason <fredg@paravelsystems.com>

* Moved execution of maintenance routines from ripcd(8) to
	rdservice(8).
This commit is contained in:
Fred Gleason
2018-08-13 16:27:12 -04:00
parent ae9296352c
commit 16661cfb6d
9 changed files with 154 additions and 119 deletions

View File

@@ -180,20 +180,6 @@ MainObject::MainObject(QObject *parent)
connect(ripcd_backup_timer,SIGNAL(timeout()),this,SLOT(databaseBackup()));
ripcd_backup_timer->start(86400000);
//
// Maintenance Routine Timer
//
srandom(QTime::currentTime().msec());
ripcd_maint_timer=new QTimer(this);
connect(ripcd_maint_timer,SIGNAL(timeout()),this,SLOT(checkMaintData()));
int interval=GetMaintInterval();
if(!rda->config()->disableMaintChecks()) {
ripcd_maint_timer->start(interval);
}
else {
log(RDConfig::LogInfo,"maintenance checks disabled on this host!");
}
//
// Exit Timer
//
@@ -371,49 +357,6 @@ void MainObject::killData(int conn_id)
}
void MainObject::checkMaintData()
{
QString sql;
RDSqlQuery *q;
QDateTime current_datetime=
QDateTime(QDate::currentDate(),QTime::currentTime());
bool run=false;
RunLocalMaintRoutine();
//
// Should we try to run system maintenance?
//
if(!rda->station()->systemMaint()) {
return;
}
//
// Get the system-wide maintenance timestamp
//
sql="lock tables VERSION write";
q=new RDSqlQuery(sql);
delete q;
sql="select LAST_MAINT_DATETIME from VERSION";
q=new RDSqlQuery(sql);
if(q->first()) {
run=1000*q->value(0).toDateTime().secsTo(current_datetime)>
RD_MAINT_MAX_INTERVAL;
}
delete q;
sql="unlock tables";
q=new RDSqlQuery(sql);
delete q;
//
// Run the routines
//
if(run) {
RunSystemMaintRoutine();
}
}
void MainObject::macroTimerData(int num)
{
ExecCart(ripc_macro_cart[num]);