mirror of
https://github.com/ElvishArtisan/rivendell.git
synced 2026-01-11 07:05:48 +01:00
2018-12-17 Fred Gleason <fredg@paravelsystems.com>
* Renamed the RD_RLM2_CLIENT_TCP_PORT define to RD_PAD_CLIENT_TCP_PORT. * Renamed the RD_RLM_SOURCE_UNIX_ADDRESS define to RD_PAD_SOURCE_UNIX_ADDRESS. * Added a RD_PYPAD_SCRIPT_DIR define. * Added an 'RDNotification::PypadType' value to the 'RDNotification::Type' enumeration. * Added 'PypadOwner=' and 'PypadGroup=' directives to the '[Identity]' section of rd.conf(5). * Added an rdpadengined(8) service. * Added a 'PYPAD_INSTANCES.IS_RUNNING' field to the database. * Added a 'PYPAD_INSTANCES.EXIT_CODE' field to the database. * Added a 'PYPAD_INSTANCES.ERROR_TEXT' field to the database. * Incremented the database version to 304.
This commit is contained in:
@@ -32,13 +32,11 @@ moc_%.cpp: %.h
|
||||
sbin_PROGRAMS = rdservice
|
||||
|
||||
dist_rdservice_SOURCES = maint_routines.cpp\
|
||||
process.cpp process.h\
|
||||
rdservice.cpp rdservice.h\
|
||||
shutdown.cpp\
|
||||
startup.cpp
|
||||
|
||||
nodist_rdservice_SOURCES = moc_process.cpp\
|
||||
moc_rdservice.cpp
|
||||
nodist_rdservice_SOURCES = moc_rdservice.cpp
|
||||
|
||||
rdservice_LDADD = @LIB_RDLIBS@ @LIBVORBIS@ @QT4_LIBS@ -lQt3Support
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ int MainObject::GetMaintInterval() const
|
||||
void MainObject::RunEphemeralProcess(int id,const QString &program,
|
||||
const QStringList &args)
|
||||
{
|
||||
svc_processes[id]=new Process(id,this);
|
||||
svc_processes[id]=new RDProcess(id,this);
|
||||
connect(svc_processes[id],SIGNAL(finished(int)),
|
||||
this,SLOT(processFinishedData(int)));
|
||||
svc_processes[id]->start(program,args);
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
// process.cpp
|
||||
//
|
||||
// Process container for the Rivendell Services Manager
|
||||
//
|
||||
// (C) Copyright 2018 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
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#include <qfile.h>
|
||||
|
||||
#include "process.h"
|
||||
|
||||
Process::Process(int id,QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
p_id=id;
|
||||
p_process=new QProcess(this);
|
||||
connect(p_process,SIGNAL(started()),this,SLOT(startedData()));
|
||||
connect(p_process,SIGNAL(finished(int,QProcess::ExitStatus)),
|
||||
this,SLOT(finishedData(int,QProcess::ExitStatus)));
|
||||
}
|
||||
|
||||
|
||||
Process::~Process()
|
||||
{
|
||||
delete p_process;
|
||||
}
|
||||
|
||||
|
||||
QProcess *Process::process() const
|
||||
{
|
||||
return p_process;
|
||||
}
|
||||
|
||||
|
||||
QString Process::program() const
|
||||
{
|
||||
return p_program;
|
||||
}
|
||||
|
||||
|
||||
QStringList Process::arguments() const
|
||||
{
|
||||
return p_arguments;
|
||||
}
|
||||
|
||||
|
||||
void Process::start(const QString &program,const QStringList &args)
|
||||
{
|
||||
p_program=program;
|
||||
p_arguments=args;
|
||||
|
||||
QFile file(p_program);
|
||||
if(!file.exists()) {
|
||||
p_error_text=tr("no such program")+" \""+p_program+"\"";
|
||||
}
|
||||
|
||||
p_process->start(program,args);
|
||||
}
|
||||
|
||||
|
||||
QString Process::errorText() const
|
||||
{
|
||||
return p_error_text;
|
||||
}
|
||||
|
||||
|
||||
void Process::startedData()
|
||||
{
|
||||
emit started(p_id);
|
||||
}
|
||||
|
||||
|
||||
void Process::finishedData(int exit_code,QProcess::ExitStatus status)
|
||||
{
|
||||
p_error_text=tr("ok");
|
||||
|
||||
if(status==QProcess::CrashExit) {
|
||||
p_error_text=tr("process crashed");
|
||||
}
|
||||
else {
|
||||
if(exit_code!=0) {
|
||||
p_error_text=tr("process returned exit code")+
|
||||
QString().sprintf(" %d ",exit_code)+
|
||||
"["+p_process->readAllStandardError()+"]";
|
||||
}
|
||||
}
|
||||
|
||||
emit finished(p_id);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
// process.h
|
||||
//
|
||||
// Process container for the Rivendell Services Manager
|
||||
//
|
||||
// (C) Copyright 2018 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
|
||||
// published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public
|
||||
// License along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
|
||||
#ifndef PROCESS_H
|
||||
#define PROCESS_H
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qprocess.h>
|
||||
|
||||
class Process : public QObject
|
||||
{
|
||||
Q_OBJECT;
|
||||
public:
|
||||
Process(int id,QObject *parent=0);
|
||||
~Process();
|
||||
QProcess *process() const;
|
||||
QString program() const;
|
||||
QStringList arguments() const;
|
||||
void start(const QString &program,const QStringList &args);
|
||||
QString errorText() const;
|
||||
|
||||
signals:
|
||||
void started(int id);
|
||||
void finished(int id);
|
||||
|
||||
private slots:
|
||||
void startedData();
|
||||
void finishedData(int exit_code,QProcess::ExitStatus status);
|
||||
|
||||
private:
|
||||
int p_id;
|
||||
QString p_program;
|
||||
QStringList p_arguments;
|
||||
QProcess *p_process;
|
||||
QString p_error_text;
|
||||
};
|
||||
|
||||
|
||||
#endif // PROCESS_H
|
||||
@@ -23,21 +23,21 @@
|
||||
|
||||
#include <qmap.h>
|
||||
#include <qobject.h>
|
||||
#include <qprocess.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include "process.h"
|
||||
#include <rdprocess.h>
|
||||
|
||||
#define RDSERVICE_CAED_ID 0
|
||||
#define RDSERVICE_RIPCD_ID 1
|
||||
#define RDSERVICE_RDCATCHD_ID 2
|
||||
#define RDSERVICE_RDPADD_ID 3
|
||||
#define RDSERVICE_RDVAIRPLAYD_ID 4
|
||||
#define RDSERVICE_RDREPLD_ID 5
|
||||
#define RDSERVICE_LOCALMAINT_ID 6
|
||||
#define RDSERVICE_SYSTEMMAINT_ID 7
|
||||
#define RDSERVICE_PURGECASTS_ID 8
|
||||
#define RDSERVICE_LAST_ID 9
|
||||
#define RDSERVICE_RDPADENGINED_ID 4
|
||||
#define RDSERVICE_RDVAIRPLAYD_ID 5
|
||||
#define RDSERVICE_RDREPLD_ID 6
|
||||
#define RDSERVICE_LOCALMAINT_ID 7
|
||||
#define RDSERVICE_SYSTEMMAINT_ID 8
|
||||
#define RDSERVICE_PURGECASTS_ID 9
|
||||
#define RDSERVICE_LAST_ID 10
|
||||
#define RDSERVICE_FIRST_DROPBOX_ID 100
|
||||
|
||||
class MainObject : public QObject
|
||||
@@ -62,7 +62,7 @@ class MainObject : public QObject
|
||||
int GetMaintInterval() const;
|
||||
void RunEphemeralProcess(int id,const QString &program,
|
||||
const QStringList &args);
|
||||
QMap<int,Process *> svc_processes;
|
||||
QMap<int,RDProcess *> svc_processes;
|
||||
QTimer *svc_maint_timer;
|
||||
QTimer *svc_exit_timer;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ void MainObject::Shutdown()
|
||||
|
||||
void MainObject::ShutdownDropboxes()
|
||||
{
|
||||
for(QMap<int,Process *>::iterator it=svc_processes.begin();
|
||||
for(QMap<int,RDProcess *>::iterator it=svc_processes.begin();
|
||||
it!=svc_processes.end();it++) {
|
||||
if(it.key()>=RDSERVICE_FIRST_DROPBOX_ID) {
|
||||
it.value()->process()->kill();
|
||||
|
||||
@@ -41,6 +41,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
//
|
||||
KillProgram("rdrepld");
|
||||
KillProgram("rdvairplayd");
|
||||
KillProgram("rdpadengined");
|
||||
KillProgram("rdpadd");
|
||||
KillProgram("rdcatchd");
|
||||
KillProgram("ripcd");
|
||||
@@ -49,7 +50,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
//
|
||||
// caed(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_CAED_ID]=new Process(RDSERVICE_CAED_ID,this);
|
||||
svc_processes[RDSERVICE_CAED_ID]=new RDProcess(RDSERVICE_CAED_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_CAED_ID]->start(QString(RD_PREFIX)+"/sbin/caed",args);
|
||||
if(!svc_processes[RDSERVICE_CAED_ID]->process()->waitForStarted(-1)) {
|
||||
@@ -61,7 +62,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
//
|
||||
// ripcd(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_RIPCD_ID]=new Process(RDSERVICE_RIPCD_ID,this);
|
||||
svc_processes[RDSERVICE_RIPCD_ID]=new RDProcess(RDSERVICE_RIPCD_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RIPCD_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/ripcd",args);
|
||||
@@ -74,7 +75,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
//
|
||||
// rdcatchd(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_RDCATCHD_ID]=new Process(RDSERVICE_RDCATCHD_ID,this);
|
||||
svc_processes[RDSERVICE_RDCATCHD_ID]=new RDProcess(RDSERVICE_RDCATCHD_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RDCATCHD_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/rdcatchd",args);
|
||||
@@ -87,7 +88,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
//
|
||||
// rdpadd(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_RDPADD_ID]=new Process(RDSERVICE_RDPADD_ID,this);
|
||||
svc_processes[RDSERVICE_RDPADD_ID]=new RDProcess(RDSERVICE_RDPADD_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RDPADD_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/rdpadd",args);
|
||||
@@ -97,10 +98,31 @@ bool MainObject::Startup(QString *err_msg)
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// *** BAND-AID * BAND_AID * YEECH! ***
|
||||
// This Makes It Work, but I think we're going to need to implement
|
||||
// socket activation on all of these services.
|
||||
//
|
||||
sleep(1);
|
||||
|
||||
//
|
||||
// rdpadengined(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_RDPADENGINED_ID]=
|
||||
new RDProcess(RDSERVICE_RDPADENGINED_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RDPADENGINED_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/rdpadengined",args);
|
||||
if(!svc_processes[RDSERVICE_RDPADENGINED_ID]->process()->waitForStarted(-1)) {
|
||||
*err_msg=tr("unable to start rdpadengined(8)")+": "+
|
||||
svc_processes[RDSERVICE_RDPADENGINED_ID]->errorText();
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// rdvairplayd(8)
|
||||
//
|
||||
svc_processes[RDSERVICE_RDVAIRPLAYD_ID]=new Process(RDSERVICE_RDVAIRPLAYD_ID,this);
|
||||
svc_processes[RDSERVICE_RDVAIRPLAYD_ID]=new RDProcess(RDSERVICE_RDVAIRPLAYD_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RDVAIRPLAYD_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/rdvairplayd",args);
|
||||
@@ -117,7 +139,7 @@ bool MainObject::Startup(QString *err_msg)
|
||||
"STATION_NAME=\""+RDEscapeString(rda->station()->name())+"\"";
|
||||
q=new RDSqlQuery(sql);
|
||||
if(q->first()) {
|
||||
svc_processes[RDSERVICE_RDREPLD_ID]=new Process(RDSERVICE_RDREPLD_ID,this);
|
||||
svc_processes[RDSERVICE_RDREPLD_ID]=new RDProcess(RDSERVICE_RDREPLD_ID,this);
|
||||
args.clear();
|
||||
svc_processes[RDSERVICE_RDREPLD_ID]->
|
||||
start(QString(RD_PREFIX)+"/sbin/rdrepld",args);
|
||||
@@ -246,7 +268,7 @@ bool MainObject::StartDropboxes(QString *err_msg)
|
||||
args.push_back(q->value(1).toString());
|
||||
args.push_back(q->value(2).toString());
|
||||
|
||||
svc_processes[id]=new Process(id,this);
|
||||
svc_processes[id]=new RDProcess(id,this);
|
||||
svc_processes[id]->start(QString(RD_PREFIX)+"/bin/rdimport",args);
|
||||
if(!svc_processes[id]->process()->waitForStarted(-1)) {
|
||||
*err_msg=tr("unable to start dropbox")+": "+
|
||||
|
||||
Reference in New Issue
Block a user