From 62513a0d23e683bc209ca12b17ea7e0ba9e9f6e9 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 1 Nov 2023 22:08:51 +0100 Subject: [PATCH] made initialization of webui as early as possible to avoir the need to restart jsonapi --- retroshare-service/src/retroshare-service.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/retroshare-service/src/retroshare-service.cc b/retroshare-service/src/retroshare-service.cc index c68a1b80a..dc543549d 100644 --- a/retroshare-service/src/retroshare-service.cc +++ b/retroshare-service/src/retroshare-service.cc @@ -219,12 +219,23 @@ int main(int argc, char* argv[]) break; } } +#ifdef RS_SERVICE_TERMINAL_WEBUI_PASSWORD + if(!webui_pass1.empty()) + { + rsWebUi->setHtmlFilesDirectory(webui_base_directory); + conf.webUIPasswd = webui_pass1; // cannot be set using rsWebUI methods because it calls the still non-existent rsJsonApi + conf.enableWebUI = true; + + // JsonApi is started below in InitRetroShare(). Not calling restart here avoids multiple restart. + } +#endif #endif /* defined(RS_JSONAPI) && defined(RS_WEBUI) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) */ conf.main_executable_path = argv[0]; int initResult = RsInit::InitRetroShare(conf); + if(initResult != RS_INIT_OK) { RsFatal() << "Retroshare core initalization failed with: " << initResult @@ -344,15 +355,6 @@ int main(int argc, char* argv[]) } #endif // def RS_SERVICE_TERMINAL_LOGIN -#if (defined(RS_JSONAPI) && defined(RS_WEBUI)) && defined(RS_SERVICE_TERMINAL_WEBUI_PASSWORD) - if(rsJsonApi && !webui_pass1.empty()) - { - rsWebUi->setHtmlFilesDirectory(webui_base_directory); - rsWebUi->setUserPassword(webui_pass1); - rsWebUi->restart(); - } -#endif - rsControl->setShutdownCallback([&](int){keepRunning = false;}); while(keepRunning)