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> 2023-01-04 Fred Gleason <fredg@paravelsystems.com>
* Corrected inaccuracies in the description of the 'Dropbox Instances' * Corrected inaccuracies in the description of the 'Dropbox Instances'
notification type in the Notifications protocol documentation. 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. // 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 // 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 // it under the terms of the GNU General Public License version 2 as
@ -21,8 +21,8 @@
#ifndef RDNOTIFICATION_H #ifndef RDNOTIFICATION_H
#define RDNOTIFICATION_H #define RDNOTIFICATION_H
#include <qstring.h> #include <QString>
#include <qvariant.h> #include <QVariant>
class RDNotification class RDNotification
{ {

View File

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