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

@@ -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);