2018-10-19 Fred Gleason <fredg@paravelsystems.com>

* Modified rdservice(8) to log errors to syslog.
	* Added an rdservice(8) man page.
	* Modified 'systemd/rivendell.service.in' to enable automatic
	start retries.
This commit is contained in:
Fred Gleason
2018-10-19 15:26:14 -04:00
parent bb5fcb6400
commit 83bd2dcd77
7 changed files with 120 additions and 90 deletions

View File

@@ -17838,3 +17838,8 @@
2018-10-19 Fred Gleason <fredg@paravelsystems.com>
* Added code in the %post and %preun rules in 'rivendell.spec.in'
to enable and disable the 'rivendell' service.
2018-10-19 Fred Gleason <fredg@paravelsystems.com>
* Modified rdservice(8) to log errors to syslog.
* Added an rdservice(8) man page.
* Modified 'systemd/rivendell.service.in' to enable automatic
start retries.

View File

@@ -38,7 +38,8 @@ all-local: rdclilogedit.1\
rdimport.1\
rdmarkerset.8\
rdrender.1\
rmlsend.1
rmlsend.1\
rdservice.8
man_MANS = rdclilogedit.1\
rdconvert.1\
@@ -47,7 +48,8 @@ man_MANS = rdclilogedit.1\
rdimport.1\
rdmarkerset.8\
rdrender.1\
rmlsend.1
rmlsend.1\
rdservice.8
EXTRA_DIST = rdclilogedit.1\
rdclilogedit.xml\
@@ -64,7 +66,9 @@ EXTRA_DIST = rdclilogedit.1\
rdrender.1\
rdrender.xml\
rmlsend.1\
rmlsend.xml
rmlsend.xm\
rdservice.8\
rdservice.xml
CLEANFILES = *~
MAINTAINERCLEANFILES = *~\

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<refentry id="stdin" xmlns="http://docbook.org/ns/docbook" version="5.0">
<!--
Header
-->
<refmeta>
<refentrytitle>rdservice</refentrytitle>
<manvolnum>8</manvolnum>
<refmiscinfo class='source'>October 2018</refmiscinfo>
<refmiscinfo class='manual'>Linux Audio Manual</refmiscinfo>
</refmeta>
<refnamediv>
<refname>rdservice</refname>
<refpurpose>Rivendell service manager</refpurpose>
</refnamediv>
<info>
<author>
<personname>
<firstname>Fred</firstname>
<surname>Gleason</surname>
<email>fredg@paravelsystems.com</email>
</personname>
<contrib>Application Author</contrib>
</author>
</info>
<!--
Body
-->
<refsynopsisdiv id='synopsis'>
<cmdsynopsis>
<command>rdservice</command>
<sbr/>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1 id='description'><title>Description</title>
<para>
<command>rdservice</command><manvolnum>8</manvolnum> manages the various
background service components of the Rivendell Radio Automation
System, including <command>caed</command><manvolnum>8</manvolnum>,
<command>rdcatchd</command><manvolnum>8</manvolnum>,
<command>ripcd</command><manvolnum>8</manvolnum>,
<command>rdvairplayd</command><manvolnum>8</manvolnum>,
<command>rdimport</command><manvolnum>1</manvolnum> (in dropbox mode)
as well as periodic system maintenance tasks using
<command>rdmaint</command><manvolnum>8</manvolnum>.
It is normally invoked by the host's boot system
(such as Systemd) at system boot-time and runs continuously thereafter.
There should only be one instance of
<command>rdservice</command><manvolnum>8</manvolnum> running at any
given time; attempts to start an additional instance will terminate
with exit code <computeroutput>1</computeroutput>.
</para>
</refsect1>
<refsect1 id='exit_values'><title>Exit Values</title>
<para>
<segmentedlist>
<?dbhtml list-presentation="tabular"?>
<?dbfo list-presentation="tabular"?>
<!-- Is there a way to suppress the title line entirely? -->
<segtitle></segtitle>
<segtitle></segtitle>
<seglistitem><seg>0</seg><seg>Normal shutdown</seg></seglistitem>
<seglistitem><seg>1</seg><seg>Prior instance found</seg></seglistitem>
<seglistitem><seg>2</seg><seg>Unable to open database</seg></seglistitem>
<seglistitem><seg>3</seg><seg>Unable to start a service component</seg></seglistitem>
</segmentedlist>
</para>
</refsect1>
<refsect1 id='see_also'><title>See Also</title>
<para>
<citerefentry>
<refentrytitle>rddbmgr</refentrytitle><manvolnum>8</manvolnum>
</citerefentry>
<literal>, </literal>
<citerefentry>
<refentrytitle>rdimport</refentrytitle><manvolnum>1</manvolnum>
</citerefentry>
</para>
</refsect1>
</refentry>

View File

@@ -56,11 +56,16 @@ MainObject::MainObject(QObject *parent)
{
QString err_msg;
//
// Open the syslog
//
openlog("rdservice",LOG_PERROR,LOG_DAEMON);
//
// Check for prior instance
//
if(RDGetPids("rdservice").size()>1) {
fprintf(stderr,"rdservice: prior instance found\n");
syslog(LOG_ERR,"prior instance found");
exit(1);
}
@@ -69,8 +74,9 @@ MainObject::MainObject(QObject *parent)
//
rda=new RDApplication("rdservice","rdservice","\n\n",this);
if(!rda->open(&err_msg)) {
fprintf(stderr,"rdservice: %s\n",(const char *)err_msg.utf8());
exit(1);
syslog(LOG_ERR,"unable to open database [%s]",
(const char *)err_msg.utf8());
exit(2);
}
//
@@ -85,8 +91,9 @@ MainObject::MainObject(QObject *parent)
if(!Startup(&err_msg)) {
Shutdown();
fprintf(stderr,"rdservice: %s\n",(const char *)err_msg.toUtf8());
exit(1);
syslog(LOG_ERR,"unable to start service component [%s]",
(const char *)err_msg.toUtf8());
exit(3);
}
//
@@ -105,7 +112,8 @@ MainObject::MainObject(QObject *parent)
}
if(!RDWritePid(RD_PID_DIR,"rdservice.pid",getuid())) {
fprintf(stderr,"rdservice: can't write pid file\n");
syslog(LOG_WARNING,"unable to write pid file to \"%s/rdservice.pid\"",
RD_PID_DIR);
}
}
@@ -124,6 +132,7 @@ void MainObject::exitData()
if(global_exiting) {
Shutdown();
RDDeletePid(RD_PID_DIR,"rdservice.pid");
syslog(LOG_DEBUG,"shutting down normally");
exit(0);
}

View File

@@ -232,85 +232,6 @@ bool MainObject::StartDropboxes(QString *err_msg)
return false;
}
id++;
/*
QString cmd=QString().
sprintf("nice rdimport --persistent-dropbox-id=%d --drop-box --log-mode",
q->value(15).toInt());
sql=QString("select SCHED_CODE from DROPBOX_SCHED_CODES where ")+
QString().sprintf("DROPBOX_ID=%d",q->value(0).toInt());
q1=new RDSqlQuery(sql);
while(q1->next()) {
cmd+=QString(" --add-scheduler-code=\"")+q1->value(0).toString()+"\"";
}
delete q1;
cmd+=
QString().sprintf(" --normalization-level=%d",q->value(3).toInt()/100);
cmd+=
QString().sprintf(" --autotrim-level=%d",q->value(4).toInt()/100);
if(q->value(5).toUInt()>0) {
cmd+=QString().sprintf(" --to-cart=%u",q->value(5).toUInt());
}
if(q->value(6).toString()=="Y") {
cmd+=" --use-cartchunk-cutid";
}
if(q->value(21).toInt()<1) {
cmd+=
QString().sprintf(" --segue-level=%d",q->value(21).toInt());
cmd+=
QString().sprintf(" --segue-length=%u",q->value(22).toUInt());
}
if(q->value(7).toString()=="Y") {
cmd+=" --title-from-cartchunk-cutid";
}
if(q->value(8).toString()=="Y") {
cmd+=" --delete-cuts";
}
if(q->value(20).toString()=="Y") {
cmd+=" --to-mono";
}
if(!q->value(9).toString().isEmpty()) {
cmd+=QString().sprintf(" \"--metadata-pattern=%s\"",
(const char *)q->value(9).toString());
}
if(q->value(10).toString()=="Y") {
cmd+=" --fix-broken-formats";
}
if(q->value(12).toString()=="Y") {
cmd+=" --delete-source";
}
if(q->value(16).toString()=="Y") {
cmd+=QString().sprintf(" --create-startdate-offset=%d",
q->value(17).toInt());
cmd+=QString().sprintf(" --create-enddate-offset=%d",
q->value(18).toInt());
}
if(!q->value(19).toString().isEmpty()) {
cmd+=" --set-user-defined="+RDEscapeString(q->value(19).toString());
}
cmd+=QString().sprintf(" --startdate-offset=%d",q->value(13).toInt());
cmd+=QString().sprintf(" --enddate-offset=%d",q->value(14).toInt());
cmd+=QString().sprintf(" %s \"%s\"",(const char *)q->value(1).toString(),
(const char *)q->value(2).toString());
if(!q->value(11).toString().isEmpty()) {
cmd+=QString().sprintf(" >> %s 2>> %s",
(const char *)q->value(11).toString(),
(const char *)q->value(11).toString());
}
else {
cmd+=" > /dev/null 2> /dev/null";
}
cmd+=" &";
LogLine(RDConfig::LogInfo,QString().
sprintf("launching dropbox configuration: \"%s\"",
(const char *)cmd));
if(fork()==0) {
system(cmd);
exit(0);
}
*/
}
delete q;
return true;
@@ -324,8 +245,8 @@ void MainObject::KillProgram(const QString &program)
while(pids.size()>0) {
for(int i=0;i<pids.size();i++) {
kill(pids.at(i),SIGKILL);
fprintf(stderr,"rdservice: killing stale program \"%s\" [%d]\n",
(const char *)program.toUtf8(),pids.at(i));
syslog(LOG_WARNING,"killing unresponsive program \"%s\" [PID: %d]",
(const char *)program.toUtf8(),pids.at(i));
}
sleep(1);
pids=RDGetPids(program);

View File

@@ -380,6 +380,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mandir}/man1/rmlsend.1.gz
%{_mandir}/man8/rddbmgr.8.gz
%{_mandir}/man8/rdmarkerset.8.gz
%{_mandir}/man8/rdservice.8.gz
@DOC_PATH@/*
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd-@VERSION@.so
@LOCAL_PREFIX@/@RD_LIB_PATH@/librd.a

View File

@@ -8,6 +8,9 @@ Type=simple
ExecStart=@prefix@/sbin/rdservice
PrivateTmp=true
Restart=always
RestartSec=10
RestartLimitInterval=120
StartLimitBurst=10
[Install]
WantedBy=multi-user.target