diff --git a/libretroshare/src/rsserver/p3webui.cc b/libretroshare/src/rsserver/p3webui.cc index a5dbf6486..a1b6ea824 100644 --- a/libretroshare/src/rsserver/p3webui.cc +++ b/libretroshare/src/rsserver/p3webui.cc @@ -130,11 +130,21 @@ public: settings->set_port( _listening_port ); settings->set_default_header( "Connection", "close" ); + if(_service->is_up()) + { + std::cerr << "WebUI is already running. Killing it." << std::endl; + _service->stop(); + } + + _service = std::make_shared(); + _service->publish( resource1 ); _service->publish( resource2 ); _service->publish( resource3 ); - _service->set_ready_handler( service_ready_handler ); + std::cerr << "Starting web service on port " << std::dec << _listening_port << std::endl; + //_service->set_ready_handler( service_ready_handler ); + try { @@ -145,6 +155,8 @@ public: RsErr() << "Could not start web interface: " << e.what() << std::endl; return; } + + std::cerr << "(II) Shutting down webui service." << std::endl; } void stop() { diff --git a/retroshare-gui/src/gui/settings/WebuiPage.cpp b/retroshare-gui/src/gui/settings/WebuiPage.cpp index 0a1c40e4c..26f7f3a0f 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.cpp +++ b/retroshare-gui/src/gui/settings/WebuiPage.cpp @@ -86,16 +86,17 @@ bool WebuiPage::updateParams(QString &errmsg) Settings->setWebinterfacePort(ui.port_SB->value()); Settings->setWebinterfaceAllowAllIps(ui.allIp_CB->isChecked()); Settings->setWebinterfaceFilesDirectory(ui.webInterfaceFiles_LE->text()); - - // apply config - checkShutdownWebui(); - ok = checkStartWebui(); } - if(!ok) - errmsg = "Could not start webinterface."; return ok; } +bool WebuiPage::restart() +{ + // apply config + checkShutdownWebui(); + + return checkStartWebui(); +} void WebuiPage::load() { std::cerr << "WebuiPage::load()" << std::endl; @@ -166,8 +167,8 @@ void WebuiPage::onAllIPCBClicked(bool /*checked*/) void WebuiPage::onApplyClicked() { QString errmsg; - bool ok = updateParams(errmsg); - if(!ok) + + if(!restart()) { QMessageBox::warning(0, tr("failed to start Webinterface"), "Failed to start the webinterface."); return; diff --git a/retroshare-gui/src/gui/settings/WebuiPage.h b/retroshare-gui/src/gui/settings/WebuiPage.h index 5141c143b..65402ed2f 100644 --- a/retroshare-gui/src/gui/settings/WebuiPage.h +++ b/retroshare-gui/src/gui/settings/WebuiPage.h @@ -68,6 +68,7 @@ private: /** Qt Designer generated object */ Ui::WebuiPage ui; + bool restart(); bool updateParams(QString &errmsg); static resource_api::ApiServer* apiServer;