forked from Silverfish/proton-bridge
GODT-1917: gRPC service should use random port.
WIP: bridge-gui wait and parse gRPC service config fie.
This commit is contained in:
@ -37,9 +37,9 @@ QMLBackend::QMLBackend()
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
/// \param[in] serviceConfig
|
||||
//****************************************************************************************************************************************************
|
||||
void QMLBackend::init()
|
||||
void QMLBackend::init(GRPCConfig const &serviceConfig)
|
||||
{
|
||||
users_ = new UserList(this);
|
||||
|
||||
@ -47,7 +47,7 @@ void QMLBackend::init()
|
||||
this->connectGrpcEvents();
|
||||
|
||||
QString error;
|
||||
if (app().grpc().connectToServer(error))
|
||||
if (app().grpc().connectToServer(serviceConfig, error))
|
||||
app().log().info("Connected to backend via gRPC service.");
|
||||
else
|
||||
throw Exception(QString("Cannot connectToServer to go backend via gRPC: %1").arg(error));
|
||||
|
||||
@ -42,7 +42,7 @@ public: // member functions.
|
||||
~QMLBackend() override = default; ///< Destructor.
|
||||
QMLBackend &operator=(QMLBackend const &) = delete; ///< Disabled assignment operator.
|
||||
QMLBackend &operator=(QMLBackend &&) = delete; ///< Disabled move assignment operator.
|
||||
void init(); ///< Initialize the backend.
|
||||
void init(GRPCConfig const &serviceConfig); ///< Initialize the backend.
|
||||
bool waitForEventStreamReaderToFinish(qint32 timeoutMs); ///< Wait for the event stream reader to finish.
|
||||
|
||||
// invokable methods can be called from QML. They generally return a value, which slots cannot do.
|
||||
|
||||
@ -41,6 +41,7 @@ namespace
|
||||
|
||||
QString const bridgeLock = "bridge-gui.lock"; ///< file name used for the lock file.
|
||||
QString const exeName = "bridge" + exeSuffix; ///< The bridge executable file name.*
|
||||
qint64 const grpcServiceConfigWaitDelayMs = 60000; ///< The wait delay for the gRPC config file in milliseconds.
|
||||
}
|
||||
|
||||
|
||||
@ -261,9 +262,16 @@ int main(int argc, char *argv[])
|
||||
log.setLevel(logLevel);
|
||||
|
||||
if (!attach)
|
||||
{
|
||||
// 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(args);
|
||||
}
|
||||
|
||||
app().backend().init();
|
||||
app().backend().init(GRPCClient::waitAndRetrieveServiceConfig(attach ? 0 : grpcServiceConfigWaitDelayMs));
|
||||
|
||||
if (!attach)
|
||||
GRPCClient::removeServiceConfigFile();
|
||||
|
||||
QQmlApplicationEngine engine;
|
||||
std::unique_ptr<QQmlComponent> rootComponent(createRootQmlComponent(engine));
|
||||
|
||||
Reference in New Issue
Block a user