mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2025-04-09 14:33:28 +02:00
2019-01-09 Fred Gleason <fredg@paravelsystems.com>
* Fixed a bug in rdpadengined(8) that caused PyPAD script errors to fail to be logged.
This commit is contained in:
parent
b92943f3e8
commit
a753f39541
@ -18337,3 +18337,6 @@
|
||||
2019-01-09 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a bug in rddbmgr(8) that caused DB corruption in multi-byte
|
||||
UTF-8 strings when reverting the schema.
|
||||
2019-01-09 Fred Gleason <fredg@paravelsystems.com>
|
||||
* Fixed a bug in rdpadengined(8) that caused PyPAD script errors
|
||||
to fail to be logged.
|
||||
|
@ -31,6 +31,8 @@ RDProcess::RDProcess(int id,QObject *parent)
|
||||
connect(p_process,SIGNAL(started()),this,SLOT(startedData()));
|
||||
connect(p_process,SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||
this,SLOT(finishedData(int,QProcess::ExitStatus)));
|
||||
connect(p_process,SIGNAL(readyReadStandardError()),
|
||||
this,SLOT(readyReadStandardErrorData()));
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +105,12 @@ void RDProcess::finishedData(int exit_code,QProcess::ExitStatus status)
|
||||
}
|
||||
|
||||
|
||||
void RDProcess::readyReadStandardErrorData()
|
||||
{
|
||||
p_standard_error_data+=process()->readAllStandardError();
|
||||
}
|
||||
|
||||
|
||||
void *RDProcess::privateData() const
|
||||
{
|
||||
return p_private_data;
|
||||
@ -113,3 +121,9 @@ void RDProcess::setPrivateData(void *priv)
|
||||
{
|
||||
p_private_data=priv;
|
||||
}
|
||||
|
||||
|
||||
QByteArray RDProcess::standardErrorData() const
|
||||
{
|
||||
return p_standard_error_data;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class RDProcess : public QObject
|
||||
QString errorText() const;
|
||||
void *privateData() const;
|
||||
void setPrivateData(void *priv);
|
||||
QByteArray standardErrorData() const;
|
||||
|
||||
signals:
|
||||
void started(int id);
|
||||
@ -45,6 +46,7 @@ class RDProcess : public QObject
|
||||
private slots:
|
||||
void startedData();
|
||||
void finishedData(int exit_code,QProcess::ExitStatus status);
|
||||
void readyReadStandardErrorData();
|
||||
|
||||
private:
|
||||
int p_id;
|
||||
@ -53,6 +55,7 @@ class RDProcess : public QObject
|
||||
QProcess *p_process;
|
||||
QString p_error_text;
|
||||
void *p_private_data;
|
||||
QByteArray p_standard_error_data;
|
||||
};
|
||||
|
||||
|
||||
|
@ -64,13 +64,17 @@ MainObject::MainObject(QObject *parent)
|
||||
//
|
||||
if(getuid()==0) {
|
||||
if(setgid(rda->config()->pypadGid())!=0) {
|
||||
fprintf(stderr,"rdpadengined: unable to set GID to %d [%s]\n",
|
||||
rda->config()->pypadGid(),strerror(errno));
|
||||
rda->log(RDConfig::LogErr,
|
||||
QString().sprintf("unable to set GID to %d [",
|
||||
rda->config()->pypadGid())+
|
||||
QString(strerror(errno))+"], exiting");
|
||||
exit(1);
|
||||
}
|
||||
if(setuid(rda->config()->pypadUid())!=0) {
|
||||
fprintf(stderr,"rdpadengined: unable to set UID to %d [%s]\n",
|
||||
rda->config()->pypadUid(),strerror(errno));
|
||||
rda->log(RDConfig::LogErr,
|
||||
QString().sprintf("unable to set UID to %d [",
|
||||
rda->config()->pypadUid())+
|
||||
QString(strerror(errno))+"], exiting");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -80,8 +84,9 @@ MainObject::MainObject(QObject *parent)
|
||||
//
|
||||
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
|
||||
if(!rda->cmdSwitch()->processed(i)) {
|
||||
fprintf(stderr,"rdpadengined: unknown command option \"%s\"\n",
|
||||
(const char *)rda->cmdSwitch()->key(i));
|
||||
rda->log(RDConfig::LogErr,
|
||||
QString("unknown command option \"")+rda->cmdSwitch()->key(i)+
|
||||
"\"");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@ -187,8 +192,9 @@ void MainObject::instanceFinishedData(int id)
|
||||
RDProcess *proc=pad_instances.value(id);
|
||||
|
||||
if(proc->process()->exitStatus()!=QProcess::NormalExit) {
|
||||
fprintf(stderr,"rdpadengined: process %d crashed\n",id);
|
||||
SetRunStatus(id,false,-1,proc->process()->readAllStandardError());
|
||||
rda->log(RDConfig::LogWarning,
|
||||
QString().sprintf("PyPAD script %d crashed\n",id));
|
||||
SetRunStatus(id,false,-1,proc->standardErrorData());
|
||||
proc->deleteLater();
|
||||
pad_instances.remove(id);
|
||||
return;
|
||||
@ -205,8 +211,11 @@ void MainObject::instanceFinishedData(int id)
|
||||
}
|
||||
else {
|
||||
if(!global_pad_exiting) {
|
||||
rda->log(RDConfig::LogWarning,
|
||||
QString().sprintf("PyPAD script ID %d exited with code %d",
|
||||
id,proc->process()->exitCode()));
|
||||
SetRunStatus(id,false,proc->process()->exitCode(),
|
||||
proc->process()->readAllStandardError());
|
||||
proc->standardErrorData());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,13 +252,14 @@ void MainObject::StartScript(unsigned id,const QString &script_path)
|
||||
connect(proc,SIGNAL(started(int)),this,SLOT(instanceStartedData(int)));
|
||||
connect(proc,SIGNAL(finished(int)),this,SLOT(instanceFinishedData(int)));
|
||||
QStringList args;
|
||||
args.push_back("-u");
|
||||
args.push_back(script_path);
|
||||
args.push_back("localhost");
|
||||
args.push_back(QString().sprintf("%u",RD_PAD_CLIENT_TCP_PORT));
|
||||
args.push_back(QString().sprintf("$%u",id));
|
||||
pad_instances.value(id)->start(RD_PYPAD_PYTHON_PATH,args);
|
||||
syslog(LOG_NOTICE,"starting: %s %s",(const char *)proc->program().toUtf8(),
|
||||
(const char *)proc->arguments().join(" ").toUtf8());
|
||||
rda->log(RDConfig::LogInfo,"starting: "+proc->program()+" "+
|
||||
proc->arguments().join(" ").toUtf8());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user