From 5c065a8e48a42cdb0a2874be6ab19dec24027699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20Gr=C3=A4f?= Date: Mon, 16 Oct 2017 22:33:18 +0200 Subject: [PATCH] Fixes in command handling --- src/App.cpp | 6 +++--- src/cc/CCClient.cpp | 10 +++++----- src/cc/ControlCommand.h | 2 +- src/cc/Service.cpp | 6 +----- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/App.cpp b/src/App.cpp index 8ca983c6..8e2ef644 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -206,7 +206,8 @@ void App::close() void App::reloadConfig() { - // reload config + // reload config WIP + /* m_self->m_options->parseConfig(m_self->m_options->configFile()); Platform::release(); @@ -221,8 +222,7 @@ void App::reloadConfig() Summary::print(); Workers::start(m_self->m_options->affinity(), m_self->m_options->priority()); - - m_self->m_options + */ } void App::onSignal(uv_signal_t *handle, int signum) diff --git a/src/cc/CCClient.cpp b/src/cc/CCClient.cpp index 9a312fab..0407a66f 100644 --- a/src/cc/CCClient.cpp +++ b/src/cc/CCClient.cpp @@ -123,9 +123,9 @@ void CCClient::publishClientStatusReport() } else if (controlCommand.getCommand() == ControlCommand::UPDATE_CONFIG) { LOG_INFO("Command: UPDATE_CONFIG received -> Updating config"); updateConfig(); - } else if (controlCommand.getCommand() == ControlCommand::RESTART) { - LOG_INFO("Command: RESTART received -> Restart"); - App::restart(); + } else if (controlCommand.getCommand() == ControlCommand::RELOAD) { + LOG_INFO("Command: RELOAD received -> Reload"); + App::reloadConfig(); } else { LOG_ERR("Command: GET_CONFIG received -> NOT IMPLEMENTED YET!"); } @@ -157,8 +157,8 @@ void CCClient::updateConfig() clientConfigFile << buffer.GetString(); clientConfigFile.close(); - LOG_INFO("Config update done. Restarting."); - App::restart(); + LOG_INFO("Config update done. Reload."); + App::reloadConfig(); } else { LOG_ERR("Not able to store client config to file %s.", m_self->m_options->configFile()); } diff --git a/src/cc/ControlCommand.h b/src/cc/ControlCommand.h index a1655287..03866c88 100644 --- a/src/cc/ControlCommand.h +++ b/src/cc/ControlCommand.h @@ -36,7 +36,7 @@ public: { START, STOP, - RESTART, + RELOAD, UPDATE_CONFIG, HALT }; diff --git a/src/cc/Service.cpp b/src/cc/Service.cpp index 04dd068c..8db4cf11 100644 --- a/src/cc/Service.cpp +++ b/src/cc/Service.cpp @@ -225,16 +225,12 @@ unsigned Service::setClientStatus(const std::string& clientId, const std::string return MHD_HTTP_BAD_REQUEST; } - if (m_clientCommand.find(clientId) != m_clientCommand.end()) { - m_clientCommand[clientId] = ControlCommand(); - } - return getClientCommand(clientId, resp); } unsigned Service::getClientCommand(const std::string& clientId, std::string& resp) { - if (m_clientCommand.find(clientId) != m_clientCommand.end()) { + if (m_clientCommand.find(clientId) == m_clientCommand.end()) { m_clientCommand[clientId] = ControlCommand(); }