2023-01-04 Fred Gleason <fredg@paravelsystems.com>

* Fixed a bug in rdpadengined(8) that caused two instances of a
	pypad script to be started when adding a single instance in
	rdadmin(1).
	* Fixed a bug in rdpadengined(8) that caused failed to clean up
	properly after a failed pypad script startup.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason 2023-01-04 17:34:37 -05:00
parent 9cccb7dadb
commit 2f295ccb9e
3 changed files with 31 additions and 13 deletions

View File

@ -23896,3 +23896,9 @@
2023-01-04 Fred Gleason <fredg@paravelsystems.com>
* Corrected inaccuracies in the description of the 'Dropbox Instances'
notification type in the Notifications protocol documentation.
2023-01-04 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdpadengined(8) that caused two instances of a
pypad script to be started when adding a single instance in
rdadmin(1).
* Fixed a bug in rdpadengined(8) that caused failed to clean up
properly after a failed pypad script startup.

View File

@ -2,7 +2,7 @@
//
// A container class for a Rivendell Notification message.
//
// (C) Copyright 2018-2022 Fred Gleason <fredg@paravelsystems.com>
// (C) Copyright 2018-2023 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
@ -21,8 +21,8 @@
#ifndef RDNOTIFICATION_H
#define RDNOTIFICATION_H
#include <qstring.h>
#include <qvariant.h>
#include <QString>
#include <QVariant>
class RDNotification
{

View File

@ -149,15 +149,17 @@ void MainObject::notificationReceivedData(RDNotification *notify)
int id=notify->id().toUInt();
switch(notify->action()) {
case RDNotification::AddAction:
sql=QString("select `ID` from `PYPAD_INSTANCES` where ")+
QString::asprintf("`ID`=%u && ",id)+
"STATION_NAME='"+RDEscapeString(rda->station()->name())+"'";
q=new RDSqlQuery(sql);
if(q->first()) {
StartScript(id);
if(pad_instances.value(id)==NULL) {
sql=QString("select `ID` from `PYPAD_INSTANCES` where ")+
QString::asprintf("`ID`=%u && ",id)+
"STATION_NAME='"+RDEscapeString(rda->station()->name())+"'";
q=new RDSqlQuery(sql);
if(q->first()) {
StartScript(id);
}
delete q;
}
delete q;
break;
break;
case RDNotification::DeleteAction:
pad_instances.value(id)->setPrivateData((void *)true); // No Restart
@ -183,7 +185,13 @@ void MainObject::notificationReceivedData(RDNotification *notify)
void MainObject::instanceStartedData(int id)
{
RDProcess *proc=NULL;
SetRunStatus(id,true);
if((proc=pad_instances.value(id))!=NULL) {
rda->syslog(LOG_INFO,"%s",(QString("started: ")+proc->program()+" "+
proc->arguments().join(" ")).toUtf8().constData());
}
}
@ -201,6 +209,8 @@ void MainObject::instanceFinishedData(int id)
if(proc->process()->exitCode()==0) {
SetRunStatus(id,false);
bool no_restart=(bool)proc->privateData();
rda->syslog(LOG_INFO,"%s",(QString("stopped: ")+proc->program()+" "+
proc->arguments().join(" ")).toUtf8().constData());
proc->deleteLater();
pad_instances.remove(id);
if(!no_restart) {
@ -214,6 +224,8 @@ void MainObject::instanceFinishedData(int id)
SetRunStatus(id,false,proc->process()->exitCode(),
proc->standardErrorData());
}
proc->deleteLater();
pad_instances.remove(id);
}
}
@ -271,8 +283,8 @@ void MainObject::StartScript(unsigned id)
args.push_back(QString::asprintf("%u",RD_PAD_CLIENT_TCP_PORT));
args.push_back(QString::asprintf("$%u",id));
pad_instances.value(id)->start(RD_PYPAD_PYTHON_PATH,args);
rda->syslog(LOG_INFO,"%s",(QString("starting: ")+proc->program()+" "+
proc->arguments().join(" ")).toUtf8().constData());
rda->syslog(LOG_DEBUG,"%s",(QString("starting: ")+proc->program()+" "+
proc->arguments().join(" ")).toUtf8().constData());
}
delete q;
}