diff --git a/ChangeLog b/ChangeLog index 98a2aba3..f75a46f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19093,3 +19093,6 @@ * Fixed a regression in rdairplay(1) and rdvairplayd(8) that caused hard timed events with the 'Start Immediately' attribute to fail to start if one or more other events were playing. +2019-09-09 Fred Gleason + * Added a 'ServiceTimeout=' directive to the '[Tuning]' section + of rd.conf(5). diff --git a/conf/rd.conf-sample b/conf/rd.conf-sample index c6413b09..aa68c3a3 100644 --- a/conf/rd.conf-sample +++ b/conf/rd.conf-sample @@ -125,7 +125,12 @@ ChannelsPerPcm=-1 ; [Tuning] -; This section defines the realtime parameters used when running +; This directive tells Rivendell modules how long to wait for the +; 'rivendell' systemd service to become active (seconds). Default +; value is '30'. +ServiceTimeout=30 + +; These directives define the realtime parameters used when running ; audio components. Normally, these are useful only for debugging. UseRealtime=Yes RealtimePriority=9 diff --git a/lib/rd.h b/lib/rd.h index f3e4b6e1..985fc810 100644 --- a/lib/rd.h +++ b/lib/rd.h @@ -600,5 +600,9 @@ #define RD_PAD_CLIENT_TCP_PORT 34289 #define RD_PAD_SOURCE_UNIX_ADDRESS "m4w8n8fsfddf-473fdueusurt-8954" +/* + * Default 'ServiceTimeout=' value in rd.conf(5) + */ +#define RD_DEFAULT_SERVICE_TIMEOUT 30 #endif // RD_H diff --git a/lib/rdapplication.cpp b/lib/rdapplication.cpp index 37b0f26e..e5898b22 100644 --- a/lib/rdapplication.cpp +++ b/lib/rdapplication.cpp @@ -341,40 +341,50 @@ void RDApplication::userChangedData() bool RDApplication::CheckService(QString *err_msg) { bool ret=false; - QStringList args; - QProcess *proc=new QProcess(this); + int trial=config()->serviceTimeout(); - args.push_back("--property"); - args.push_back("ActiveState"); - args.push_back("show"); - args.push_back("rivendell"); - proc->start("systemctl",args); - proc->waitForFinished(); - if(proc->exitStatus()!=QProcess::NormalExit) { - *err_msg=tr("systemctl(1) crashed."); + if(trial<=0) { + trial=1; } - else { - if(proc->exitCode()!=0) { - *err_msg=tr("systemctl(1) returned exit code")+ - QString().sprintf(" %d:\n",proc->exitCode())+ - proc->readAllStandardError(); + while((!ret)&&(trial>0)) { + QStringList args; + QProcess *proc=new QProcess(this); + + args.push_back("--property"); + args.push_back("ActiveState"); + args.push_back("show"); + args.push_back("rivendell"); + proc->start("systemctl",args); + proc->waitForFinished(); + if(proc->exitStatus()!=QProcess::NormalExit) { + *err_msg=tr("systemctl(1) crashed."); } else { - *err_msg=tr("Rivendell service is not active."); - QStringList f0=QString(proc->readAllStandardOutput()). - split("\n",QString::SkipEmptyParts); - for(int i=0;iexitCode()!=0) { + *err_msg=tr("systemctl(1) returned exit code")+ + QString().sprintf(" %d:\n",proc->exitCode())+ + proc->readAllStandardError(); + } + else { + *err_msg=tr("Rivendell service is not active."); + QStringList f0=QString(proc->readAllStandardOutput()). + split("\n",QString::SkipEmptyParts); + for(int i=0;iboolValue("Tuning","UseRealtime",false); conf_realtime_priority=profile->intValue("Tuning","RealtimePriority",9); conf_transcoding_delay=profile->intValue("Tuning","TranscodingDelay"); + conf_service_timeout= + profile->intValue("Tuning","ServiceTimeout",RD_DEFAULT_SERVICE_TIMEOUT); conf_temp_directory=profile->stringValue("Tuning","TempDirectory",""); conf_sas_station=profile->stringValue("SASFilter","Station",""); conf_sas_matrix=profile->intValue("SASFilter","Matrix",0); @@ -681,6 +690,7 @@ void RDConfig::clear() conf_use_realtime=false; conf_realtime_priority=9; conf_transcoding_delay=0; + conf_service_timeout=RD_DEFAULT_SERVICE_TIMEOUT; conf_temp_directory=""; conf_sas_station=""; conf_sas_matrix=-1; diff --git a/lib/rdconfig.h b/lib/rdconfig.h index b06a75a1..f1111dc9 100644 --- a/lib/rdconfig.h +++ b/lib/rdconfig.h @@ -106,6 +106,7 @@ class RDConfig bool useRealtime(); int realtimePriority(); int transcodingDelay() const; + int serviceTimeout() const; QString tempDirectory(); QString sasStation() const; int sasMatrix() const; @@ -172,6 +173,7 @@ class RDConfig bool conf_use_realtime; int conf_transcoding_delay; int conf_realtime_priority; + int conf_service_timeout; QString conf_temp_directory; QString conf_sas_station; int conf_sas_matrix;