-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Address comments and improve the code
- Loading branch information
Showing
12 changed files
with
130 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
project(RestartHandler) | ||
|
||
include(../../cmake/CommonSettings.cmake) | ||
set_common_settings() | ||
|
||
find_package(Boost REQUIRED COMPONENTS asio) | ||
|
||
|
||
if(WIN32) | ||
set(SOURCES src/restart_handler_win.cpp) | ||
else() | ||
set(SOURCES src/restart_handler_unix.cpp) | ||
endif() | ||
|
||
add_library(RestartHandler ${SOURCES}) | ||
target_include_directories(RestartHandler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
target_link_libraries(RestartHandler PUBLIC Boost::asio CommandEntry PRIVATE Logger) | ||
|
||
include(../../cmake/ConfigureTarget.cmake) | ||
configure_target(RestartHandler) | ||
|
||
# if(BUILD_TESTS) | ||
# enable_testing() | ||
# add_subdirectory(tests) | ||
# endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
#include <command_entry.hpp> | ||
|
||
#include <boost/asio/awaitable.hpp> | ||
|
||
#include <vector> | ||
|
||
namespace restart_handler | ||
{ | ||
/// @brief Class for handling service restarts. | ||
class RestartHandler | ||
{ | ||
public: | ||
/// @brief Command-line arguments for the service. | ||
static std::vector<char*> cmd_line; | ||
explicit RestartHandler(); | ||
|
||
/// @brief Stores the command-line arguments passed to the agent. | ||
/// @param argc Number of arguments. | ||
/// @param argv Array of arguments. | ||
static void SetCommandLineArguments(int argc, char* argv[]) | ||
{ | ||
for (int i = 0; i < argc; ++i) | ||
{ | ||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) | ||
RestartHandler::cmd_line.emplace_back(argv[i]); | ||
} | ||
RestartHandler::cmd_line.emplace_back(nullptr); | ||
} | ||
|
||
/// @brief Executes the restart command. | ||
/// @return Result of the restart command execution. | ||
static boost::asio::awaitable<module_command::CommandExecutionResult> RestartCommand(); | ||
}; | ||
} // namespace restart_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
src/agent/restart/src/restart_win.cpp → ...start_handler/src/restart_handler_win.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
#include <boost/asio/awaitable.hpp> | ||
#include <logger.hpp> | ||
#include <restart.hpp> | ||
#include <restart_handler.hpp> | ||
|
||
namespace restart | ||
namespace restart_handler | ||
{ | ||
|
||
boost::asio::awaitable<module_command::CommandExecutionResult> Restart::HandleRestartCommand() | ||
std::vector<char*> RestartHandler::cmd_line; | ||
|
||
boost::asio::awaitable<module_command::CommandExecutionResult> RestartHandler::RestartCommand() | ||
{ | ||
// TODO | ||
co_return module_command::CommandExecutionResult {module_command::Status::FAILURE, | ||
"Restart is not implemented yet"}; | ||
"RestartHandler is not implemented yet"}; | ||
} | ||
|
||
} // namespace restart | ||
} // namespace restart_handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters