mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-06-05 14:42:35 +02:00
2021-05-28 Fred Gleason <fredg@paravelsystems.com>
* Added syslog DEBUG messages around the start/stop of ephemeral processes in rdservice(8). * Added an '--initial-maintenance' switch to rdservice(8). Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
parent
dd5eaa1b21
commit
f7565ef11c
@ -20757,3 +20757,7 @@
|
||||
2021-05-28 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a use-after-delete bug in rdimport(1) that could cause
|
||||
a segfault when the '--fix-broken-formats' switch was given.
|
||||
2021-05-28 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Added syslog DEBUG messages around the start/stop of ephemeral
|
||||
processes in rdservice(8).
|
||||
* Added an '--initial-maintenance' switch to rdservice(8).
|
||||
|
@ -89,6 +89,18 @@
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--initial-maintenance-interval=<replaceable>interval</replaceable></option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Schedule the initial maintenance run to be started
|
||||
<replaceable>interval</replaceable> milliseconds after startup.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Rivendell Maintenance Routines
|
||||
//
|
||||
// (C) Copyright 2008-2020 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2008-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -23,12 +23,15 @@
|
||||
|
||||
#include <rd.h>
|
||||
#include <rdapplication.h>
|
||||
#include <rdconf.h>
|
||||
#include <rdpaths.h>
|
||||
|
||||
#include "rdservice.h"
|
||||
|
||||
void MainObject::checkMaintData()
|
||||
{
|
||||
rda->syslog(LOG_DEBUG,"starting maintenance checks");
|
||||
|
||||
QString sql;
|
||||
RDSqlQuery *q;
|
||||
QDateTime current_datetime=
|
||||
@ -38,7 +41,12 @@ void MainObject::checkMaintData()
|
||||
//
|
||||
// Schedule Next Maintenance Run
|
||||
//
|
||||
svc_maint_timer->start(GetMaintInterval());
|
||||
int interval=GetMaintInterval();
|
||||
svc_maint_timer->start(interval);
|
||||
rda->syslog(LOG_DEBUG,"next maintenance run at %s [%s from now]",
|
||||
QDateTime::currentDateTime().addMSecs(interval).
|
||||
toString("hh:mm:ss").toUtf8().constData(),
|
||||
RDGetTimeLength(interval,false,false).toUtf8().constData());
|
||||
|
||||
RunLocalMaintRoutine();
|
||||
|
||||
@ -107,12 +115,15 @@ int MainObject::GetMaintInterval() const
|
||||
void MainObject::RunEphemeralProcess(int id,const QString &program,
|
||||
const QStringList &args)
|
||||
{
|
||||
rda->syslog(LOG_DEBUG,"starting ephemeral process \"%s\"",
|
||||
(program+" "+args.join(" ")).trimmed().toUtf8().constData());
|
||||
svc_processes[id]=new RDProcess(id,this);
|
||||
connect(svc_processes[id],SIGNAL(finished(int)),
|
||||
this,SLOT(processFinishedData(int)));
|
||||
svc_processes[id]->start(program,args);
|
||||
if(!svc_processes[id]->process()->waitForStarted()) {
|
||||
QString err_msg=tr("unable to start")+"\""+program+"\": "+
|
||||
QString err_msg=tr("unable to start ephemeral process ")+
|
||||
"\""+(program+" "+args.join(" ")).trimmed()+"\": "+
|
||||
svc_processes[id]->errorText();
|
||||
rda->syslog(LOG_WARNING,"%s",(const char *)err_msg.toUtf8());
|
||||
delete svc_processes[id];
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// Rivendell Services Manager
|
||||
//
|
||||
// (C) Copyright 2018-2019 Fred Gleason <fredg@paravelsystems.com>
|
||||
// (C) Copyright 2018-2021 Fred Gleason <fredg@paravelsystems.com>
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -57,6 +57,8 @@ MainObject::MainObject(QObject *parent)
|
||||
{
|
||||
QString err_msg;
|
||||
RDApplication::ErrorType err_type=RDApplication::ErrorOk;
|
||||
int initial_maintenance_interval=-1;
|
||||
bool ok=false;
|
||||
|
||||
svc_startup_target=MainObject::TargetAll;
|
||||
|
||||
@ -77,6 +79,7 @@ MainObject::MainObject(QObject *parent)
|
||||
(const char *)err_msg.utf8());
|
||||
exit(RDApplication::ExitNoDb);
|
||||
}
|
||||
rda->syslog(LOG_DEBUG,"starting up");
|
||||
|
||||
//
|
||||
// Process Startup Options
|
||||
@ -88,6 +91,15 @@ MainObject::MainObject(QObject *parent)
|
||||
svc_startup_target=target;
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
if(rda->cmdSwitch()->key(i)=="--initial-maintenance-interval") {
|
||||
initial_maintenance_interval=rda->cmdSwitch()->value(i).toInt(&ok);
|
||||
if(!ok) {
|
||||
fprintf(stderr,
|
||||
"rdservice: invalid \"--initial-maintenance-interval\" value\n");
|
||||
exit(4);
|
||||
}
|
||||
rda->cmdSwitch()->setProcessed(i,true);
|
||||
}
|
||||
}
|
||||
if(!rda->cmdSwitch()->processed(i)) {
|
||||
fprintf(stderr,"rdservice: unknown command-line option\n");
|
||||
@ -121,6 +133,13 @@ MainObject::MainObject(QObject *parent)
|
||||
connect(svc_maint_timer,SIGNAL(timeout()),this,SLOT(checkMaintData()));
|
||||
int interval=GetMaintInterval();
|
||||
if(!rda->config()->disableMaintChecks()) {
|
||||
if(initial_maintenance_interval>=0) {
|
||||
interval=initial_maintenance_interval;
|
||||
}
|
||||
rda->syslog(LOG_DEBUG,"initial maintenance run at %s [%s from now]",
|
||||
QDateTime::currentDateTime().addMSecs(interval).
|
||||
toString("hh:mm:ss").toUtf8().constData(),
|
||||
RDGetTimeLength(interval,false,false).toUtf8().constData());
|
||||
svc_maint_timer->start(interval);
|
||||
}
|
||||
else {
|
||||
@ -136,7 +155,26 @@ MainObject::MainObject(QObject *parent)
|
||||
|
||||
void MainObject::processFinishedData(int id)
|
||||
{
|
||||
svc_processes[id]->deleteLater();
|
||||
RDProcess *proc=svc_processes.value(id);
|
||||
if(proc->process()->exitStatus()!=QProcess::NormalExit) {
|
||||
rda->syslog(LOG_WARNING,"process \"%s\" crashed!",
|
||||
(proc->program()+" "+proc->arguments().join(" ").trimmed()).
|
||||
toUtf8().constData());
|
||||
}
|
||||
else {
|
||||
if(proc->process()->exitCode()!=0) {
|
||||
rda->syslog(LOG_WARNING,"process \"%s\" exited with exit code %d",
|
||||
(proc->program()+" "+proc->arguments().join(" ").trimmed()).
|
||||
toUtf8().constData(),
|
||||
proc->process()->exitCode());
|
||||
}
|
||||
else {
|
||||
rda->syslog(LOG_DEBUG,"process \"%s\" exited normally",
|
||||
(proc->program()+" "+proc->arguments().join(" ").trimmed()).
|
||||
toUtf8().constData());
|
||||
}
|
||||
}
|
||||
proc->process()->deleteLater();
|
||||
svc_processes.remove(id);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user