GODT-1671: Implement Quit & Restart mechanism

This commit is contained in:
Romain LE JEUNE
2022-07-28 16:39:56 +02:00
committed by Jakub
parent f44d1c4b9d
commit 22a8aab151
26 changed files with 1255 additions and 701 deletions

View File

@ -34,7 +34,7 @@ QString const exeSuffix = ".exe";
QString const exeSuffix;
#endif
QString const exeName = "bridge" + exeSuffix; ///< The bridge executable file name.
QString const exeName = "proton-bridge" + exeSuffix; ///< The bridge executable file name.*
}
@ -55,9 +55,10 @@ QString BridgeMonitor::locateBridgeExe()
/// \param[in] exePath The path of the Bridge executable.
/// \param[in] parent The parent object of the worker.
//****************************************************************************************************************************************************
BridgeMonitor::BridgeMonitor(QString const &exePath, QObject *parent)
BridgeMonitor::BridgeMonitor(QString const &exePath, QStringList const &args, QObject *parent)
: Worker(parent)
, exePath_(exePath)
, args_(args)
{
QFileInfo fileInfo(exePath);
if (!fileInfo.exists())
@ -77,16 +78,23 @@ void BridgeMonitor::run()
emit started();
QProcess p;
p.start(exePath_, QStringList());
p.start(exePath_, args_);
p.waitForStarted();
status_.running = true;
status_.pid = p.processId();
while (!p.waitForFinished(100))
{
// we discard output from bridge, it's logged to file on bridge side.
p.readAllStandardError();
p.readAllStandardOutput();
}
emit processExited(p.exitCode());
status_.running = false;
status_.returnCode = p.exitCode();
emit processExited(status_.returnCode );
emit finished();
}
catch (Exception const &e)
@ -94,3 +102,11 @@ void BridgeMonitor::run()
emit error(e.qwhat());
}
}
//****************************************************************************************************************************************************
/// \return status of the monitored process
//****************************************************************************************************************************************************
const BridgeMonitor::MonitorStatus& BridgeMonitor::getStatus()
{
return status_;
}