|
@@ -126,11 +126,13 @@ std::vector<ProgUnit> ProgMon::loadprogunit(std::string path)
|
|
|
QDomElement e = n.toElement(); // 尝试将节点转换为元素
|
|
|
std::string name = e.nodeName().toStdString();
|
|
|
|
|
|
- if(name == "module")
|
|
|
+ if(name == "launch")
|
|
|
{
|
|
|
- std::string appname = e.attribute("app","").toStdString();
|
|
|
+
|
|
|
+ // std::cout<<" have a launch"<<std::endl;
|
|
|
+ std::string launchname = e.attribute("launch","").toStdString();
|
|
|
std::string strdir = e.attribute("dir","").toStdString();
|
|
|
- std::string strargs = e.attribute("args","").toStdString();
|
|
|
+ std::string strmodulename = e.attribute("moudulename","").toStdString();
|
|
|
std::string strbstart = e.attribute("autostart","false").toStdString();
|
|
|
std::string strgroup = e.attribute("group","unknown").toStdString();
|
|
|
std::string strsavestd = e.attribute("savestd","false").toStdString();
|
|
@@ -139,8 +141,8 @@ std::vector<ProgUnit> ProgMon::loadprogunit(std::string path)
|
|
|
if(strbstart == "true")x.mbautostart = true;
|
|
|
else x.mbautostart = false;
|
|
|
x.strappdir = strdir;
|
|
|
- x.strappname = appname;
|
|
|
- x.strargs = strargs;
|
|
|
+ x.strlaunch = launchname;
|
|
|
+ x.strmodulename = strmodulename;
|
|
|
x.strgroup = strgroup;
|
|
|
x.mProcess = 0;
|
|
|
x.mbSavestdout = false;
|
|
@@ -148,7 +150,7 @@ std::vector<ProgUnit> ProgMon::loadprogunit(std::string path)
|
|
|
|
|
|
|
|
|
|
|
|
- if(x.strappname.length() > 0)
|
|
|
+ if(x.strlaunch.length() > 0)
|
|
|
{
|
|
|
x.strcmd = x.strappdir;
|
|
|
if(x.strcmd.length()<1)
|
|
@@ -162,12 +164,12 @@ std::vector<ProgUnit> ProgMon::loadprogunit(std::string path)
|
|
|
x.strcmd.append("/");
|
|
|
}
|
|
|
}
|
|
|
- x.strcmd.append(x.strappname);
|
|
|
- if(x.strargs.length() > 0)
|
|
|
- {
|
|
|
- x.strcmd.append(" ");
|
|
|
- x.strcmd.append(x.strargs);
|
|
|
- }
|
|
|
+ x.strcmd.append(x.strlaunch);
|
|
|
+// if(x.strargs.length() > 0)
|
|
|
+// {
|
|
|
+// x.strcmd.append(" ");
|
|
|
+// x.strcmd.append(x.strargs);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
xvectorprog.push_back(x);
|
|
@@ -296,7 +298,7 @@ void ProgMon::onProcessErrorStarted(QProcess::ProcessError error){
|
|
|
//未知错误 启动失败
|
|
|
code = 0x0002;
|
|
|
}
|
|
|
- desc = mvectorprog.at(i).strappname + ":FailedToStart";
|
|
|
+ desc = mvectorprog.at(i).strlaunch + ":FailedToStart";
|
|
|
//记录故障状态,模块启动失败
|
|
|
// ivfault->SetFaultState(2,code,desc.c_str());
|
|
|
}
|
|
@@ -360,7 +362,7 @@ void ProgMon::onProcessEnd()
|
|
|
|
|
|
if(mbquit)
|
|
|
{
|
|
|
- std::cout<<"Program "<<pu->strappname<<" quit."<<std::endl;
|
|
|
+ std::cout<<"Program "<<pu->strlaunch<<" quit."<<std::endl;
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -471,7 +473,7 @@ ProgUnit * ProgMon::FindProcByName(std::string strappname, std::string strargs)
|
|
|
ProgUnit * putem = &mvectorprog.at(i);
|
|
|
if(strargs.size()<1)
|
|
|
{
|
|
|
- if(strappname == putem->strappname)
|
|
|
+ if(strappname == putem->strlaunch)
|
|
|
{
|
|
|
pu = putem;
|
|
|
break;
|
|
@@ -479,7 +481,7 @@ ProgUnit * ProgMon::FindProcByName(std::string strappname, std::string strargs)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if((strappname == putem->strappname)&&(strargs == putem->strargs))
|
|
|
+ if((strappname == putem->strlaunch)&&(strargs == putem->strmodulename))
|
|
|
{
|
|
|
pu = putem;
|
|
|
break;
|
|
@@ -524,24 +526,12 @@ void ProgMon::StartProc(ProgUnit *pu)
|
|
|
{
|
|
|
if(pu->mbRun)
|
|
|
{
|
|
|
- qDebug("process %s is running. not need start.",pu->strappname.data());
|
|
|
+ qDebug("process %s is running. not need start.",pu->strlaunch.data());
|
|
|
return;
|
|
|
}
|
|
|
pu->mProcess = new QProcess(this);
|
|
|
|
|
|
-
|
|
|
- connect(pu->mProcess,SIGNAL(started()),this,SLOT(onProcessStarted()));
|
|
|
- connect(pu->mProcess,SIGNAL(finished(int)),this,SLOT(onProcessEnd()));
|
|
|
-// connect(pu->mProcess,SIGNAL(readyRead()),this,SLOT(onChRead()));
|
|
|
- connect(pu->mProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(onReadStandardOutput()));
|
|
|
- connect(pu->mProcess,SIGNAL(readyReadStandardError()),this,SLOT(onReadStandardError()));
|
|
|
-
|
|
|
-
|
|
|
- connect(pu->mProcess,SIGNAL(error(QProcess::ProcessError)),this,SLOT(onProcessErrorStarted(QProcess::ProcessError)));
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- pu->mProcess->start(pu->strcmd.data());
|
|
|
+ pu->mProcess->start("cyber_launch",QStringList() << "start"<<pu->strcmd.data());
|
|
|
pu->state = 1;
|
|
|
|
|
|
|
|
@@ -563,29 +553,13 @@ void ProgMon::StopProc(ProgUnit *pu)
|
|
|
{
|
|
|
if(pu == 0)return;
|
|
|
if(pu->mProcess == 0)return;
|
|
|
- if(!pu->mbRun)
|
|
|
- {
|
|
|
- qDebug("process %s is not running. not need stop.",pu->strappname.data());
|
|
|
- return;
|
|
|
- }
|
|
|
- pu->mProcess->terminate();
|
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(300));
|
|
|
- pu->mProcess->kill();
|
|
|
-
|
|
|
- if(!checkStartState(pu)){
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- //modify tjc
|
|
|
- //发送dbus信号使程序退出
|
|
|
- QDBusMessage msg = QDBusMessage::createSignal("/catarc/adc", "adciv.sys.stop.interface", pu->strappname.data());
|
|
|
- QDBusConnection::sessionBus().send(msg);
|
|
|
-// ivlog->info("dispatch %s exit", pu->strappname.c_str());
|
|
|
- pu->state = 0;
|
|
|
- emit checkExit(pu);
|
|
|
+ std::cout<<" stop launch "<<pu->strcmd<<std::endl;
|
|
|
+ pu->mProcess = new QProcess(this);
|
|
|
+ pu->mProcess->start("cyber_launch",QStringList() << "stop"<<pu->strcmd.data());
|
|
|
}
|
|
|
|
|
|
void ProgMon::ForceStopProc(ProgUnit *pu){
|
|
|
+ std::cout<<" force stop."<<std::endl;
|
|
|
if(pu == 0)return;
|
|
|
if(pu->mProcess == 0)return;
|
|
|
pu->mProcess->kill();
|
|
@@ -597,7 +571,7 @@ void ProgMon::ForceStopProc(ProgUnit *pu){
|
|
|
|
|
|
//modify tjc
|
|
|
//发送dbus信号使程序退出
|
|
|
- QDBusMessage msg = QDBusMessage::createSignal("/catarc/adc", "adciv.sys.stop.interface", pu->strappname.data());
|
|
|
+ QDBusMessage msg = QDBusMessage::createSignal("/catarc/adc", "adciv.sys.stop.interface", pu->strlaunch.data());
|
|
|
QDBusConnection::sessionBus().send(msg);
|
|
|
// ivlog->info("dispatch %s exit", pu->strappname.c_str());
|
|
|
pu->state = 0;
|
|
@@ -744,8 +718,8 @@ void ProgMon::threaderrout()
|
|
|
ProgUnit *pu = &(mvectorprog.at(j));
|
|
|
if(xvectorerrout[i].mpProc == pu->mProcess)
|
|
|
{
|
|
|
- strappname = pu->strappname;
|
|
|
- strarg = pu->strargs;
|
|
|
+ strappname = pu->strlaunch;
|
|
|
+ strarg = pu->strmodulename;
|
|
|
bFind = true;
|
|
|
break;
|
|
|
}
|
|
@@ -861,8 +835,8 @@ void ProgMon::threadstdout()
|
|
|
ProgUnit *pu = &(mvectorprog.at(j));
|
|
|
if(xvectorstdout[i].mpProc == pu->mProcess)
|
|
|
{
|
|
|
- strappname = pu->strappname;
|
|
|
- strarg = pu->strargs;
|
|
|
+ strappname = pu->strlaunch;
|
|
|
+ strarg = pu->strmodulename;
|
|
|
bFind = true;
|
|
|
bSave = pu->mbSavestdout;
|
|
|
break;
|
|
@@ -939,8 +913,8 @@ void ProgMon::LogError(QProcess *proc, QByteArray &ba)
|
|
|
ProgUnit *pu = &(mvectorprog.at(i));
|
|
|
if(proc == pu->mProcess)
|
|
|
{
|
|
|
- strappname = pu->strappname;
|
|
|
- strarg = pu->strargs;
|
|
|
+ strappname = pu->strlaunch;
|
|
|
+ strarg = pu->strmodulename;
|
|
|
bFind = true;
|
|
|
break;
|
|
|
}
|