diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-12-08 10:00:48 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-12-12 14:37:18 +0100 |
commit | c26ec6a240877717157ac76357e2ba2496fcd9d6 (patch) | |
tree | cb28589aaad6628cbed53ea9debe94f8ae9b1d5c /src | |
parent | 708e0ada1aa52f0627f0554ad01b8d22e099850c (diff) | |
download | justbuild-c26ec6a240877717157ac76357e2ba2496fcd9d6.tar.gz |
just serve: Fix handling of missing remote execution endpoint
Only the client needs to make sure that the remote execution
endpoint is set in the case 'just serve' acts also as
'just execute', i.e., when a remote execution endpoint is not
specified, while for setting up the serve server a missing
execution endpoint should remain unset.
Diffstat (limited to 'src')
3 files changed, 19 insertions, 22 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 65daa0d8..ad1447be 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -146,21 +146,6 @@ void SetupServeConfig(ServeArguments const& srvargs, *srvargs.remote_serve_address); std::exit(kExitFailure); } - // if the user has not provided the --remote-execution-address, we fall - // back to the --remote-serve-address - if (auto client_remote_address = RemoteExecutionConfig::RemoteAddress(); - !client_remote_address) { - if (!RemoteExecutionConfig::SetRemoteAddress( - *srvargs.remote_serve_address)) { - Logger::Log(LogLevel::Error, - "Setting remote execution address '{}' failed.", - *srvargs.remote_serve_address); - std::exit(kExitFailure); - } - Logger::Log(LogLevel::Info, - "Using '{}' as the remote execution endpoint.", - *srvargs.remote_serve_address); - } } if (not srvargs.repositories.empty() and not RemoteServeConfig::SetKnownRepositories(srvargs.repositories)) { @@ -863,6 +848,22 @@ auto main(int argc, char* argv[]) -> int { } return kExitSuccess; } + + // If no execution endpoint was given, the client should default to the + // serve endpoint, if given + if (not RemoteExecutionConfig::RemoteAddress() and + arguments.serve.remote_serve_address) { + if (!RemoteExecutionConfig::SetRemoteAddress( + *arguments.serve.remote_serve_address)) { + Logger::Log(LogLevel::Error, + "Setting remote execution address '{}' failed.", + *arguments.serve.remote_serve_address); + std::exit(kExitFailure); + } + Logger::Log(LogLevel::Info, + "Using '{}' as the remote execution endpoint.", + *arguments.serve.remote_serve_address); + } #endif // BOOTSTRAP_BUILD_TOOL auto jobs = arguments.build.build_jobs > 0 ? arguments.build.build_jobs diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp index 16aa6466..1c0453e5 100644 --- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp +++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp @@ -121,13 +121,6 @@ auto ServeServerImpl::Run(bool with_execute) -> bool { return false; } - if (with_execute and !RemoteExecutionConfig::SetRemoteAddress( - fmt::format("{}:{}", interface_, port_))) { - Logger::Log(LogLevel::Error, - "Internal error: cannot set the remote address"); - return false; - } - auto pid = getpid(); nlohmann::json const& info = { diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp index 494165ed..1bf1a1cc 100644 --- a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp +++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp @@ -47,6 +47,9 @@ class ServeServerImpl { ServeServerImpl(ServeServerImpl&&) noexcept = delete; auto operator=(ServeServerImpl&&) noexcept -> ServeServerImpl& = delete; + /// \brief Start the serve service. + /// \param with_execute Flag specifying if just serve should act also as + /// just execute (i.e., start remote execution services with same interface) auto Run(bool with_execute) -> bool; ~ServeServerImpl() = default; |