fix(GODT-2458): Wait for both bridge and bridge-gui to be ended before restarting on crash.

This commit is contained in:
Romain Le Jeune
2023-03-07 15:44:58 +00:00
parent 59cf5e890b
commit 3ca56cfab3
3 changed files with 41 additions and 11 deletions

View File

@ -248,7 +248,7 @@ void focusOtherInstance() {
//****************************************************************************************************************************************************
/// \param [in] args list of arguments to pass to bridge.
//****************************************************************************************************************************************************
void launchBridge(QStringList const &args) {
const QString launchBridge(QStringList const &args) {
UPOverseer &overseer = app().bridgeOverseer();
overseer.reset();
@ -265,6 +265,7 @@ void launchBridge(QStringList const &args) {
app().log().info(QString("Launching bridge process with command \"%1\" %2").arg(bridgeExePath, params.join(" ")));
overseer = std::make_unique<Overseer>(new ProcessMonitor(bridgeExePath, params, nullptr), nullptr);
overseer->startWorker(true);
return bridgeExePath;
}
@ -330,7 +331,7 @@ int main(int argc, char *argv[]) {
// When not in attached mode, log entries are forwarded to bridge, which output it on stdout/stderr. bridge-gui's process monitor intercept
// these outputs and output them on the command-line.
log.setLevel(cliOptions.logLevel);
QString bridgeexec;
if (!cliOptions.attach) {
if (isBridgeRunning()) {
throw Exception("An orphan instance of bridge is already running. Please terminate it and relaunch the application.",
@ -339,7 +340,7 @@ int main(int argc, char *argv[]) {
// before launching bridge, we remove any trailing service config file, because we need to make sure we get a newly generated one.
GRPCClient::removeServiceConfigFile();
launchBridge(cliOptions.bridgeArgs);
bridgeexec = launchBridge(cliOptions.bridgeArgs);
}
log.info(QString("Retrieving gRPC service configuration from '%1'").arg(QDir::toNativeSeparators(grpcServerConfigPath())));
@ -401,6 +402,10 @@ int main(int argc, char *argv[]) {
QStringList args = cliOptions.bridgeGuiArgs;
args.append(waitFlag);
args.append(mainexec);
if (!bridgeexec.isEmpty()) {
args.append(waitFlag);
args.append(bridgeexec);
}
app().setLauncherArgs(cliOptions.launcher, args);
result = QGuiApplication::exec();
}