summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/main/main.cpp3
-rw-r--r--src/buildtool/serve_api/serve_service/TARGETS6
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.cpp64
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.hpp2
4 files changed, 57 insertions, 18 deletions
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index b6e7b63f..d6b06471 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -971,7 +971,8 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kServe) {
SetupServeServiceConfig(arguments.service);
- if (!ServeServerImpl::Instance().Run()) {
+ if (!ServeServerImpl::Instance().Run(
+ !RemoteExecutionConfig::RemoteAddress())) {
return kExitFailure;
}
return kExitSuccess;
diff --git a/src/buildtool/serve_api/serve_service/TARGETS b/src/buildtool/serve_api/serve_service/TARGETS
index 953da5d6..5e00b3d1 100644
--- a/src/buildtool/serve_api/serve_service/TARGETS
+++ b/src/buildtool/serve_api/serve_service/TARGETS
@@ -53,6 +53,12 @@
, ["src/buildtool/common/remote", "port"]
, ["src/buildtool/compatibility", "compatibility"]
, ["src/buildtool/storage", "config"]
+ , ["src/buildtool/execution_api/execution_service", "execution_server"]
+ , ["src/buildtool/execution_api/execution_service", "ac_server"]
+ , ["src/buildtool/execution_api/execution_service", "cas_server"]
+ , ["src/buildtool/execution_api/execution_service", "bytestream_server"]
+ , ["src/buildtool/execution_api/execution_service", "capabilities_server"]
+ , ["src/buildtool/execution_api/execution_service", "operations_server"]
]
}
}
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 f1113cdd..7eea7d91 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
@@ -25,6 +25,12 @@
#include "src/buildtool/auth/authentication.hpp"
#include "src/buildtool/common/remote/port.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
+#include "src/buildtool/execution_api/execution_service/ac_server.hpp"
+#include "src/buildtool/execution_api/execution_service/bytestream_server.hpp"
+#include "src/buildtool/execution_api/execution_service/capabilities_server.hpp"
+#include "src/buildtool/execution_api/execution_service/cas_server.hpp"
+#include "src/buildtool/execution_api/execution_service/execution_server.hpp"
+#include "src/buildtool/execution_api/execution_service/operations_server.hpp"
#include "src/buildtool/file_system/file_system_manager.hpp"
#include "src/buildtool/file_system/git_repo.hpp"
#include "src/buildtool/logging/logger.hpp"
@@ -46,13 +52,44 @@ auto TryWrite(std::string const& file, T const& content) noexcept -> bool {
}
} // namespace
-auto ServeServerImpl::Run() -> bool {
+auto ServeServerImpl::Run(bool with_execute) -> bool {
+ // make sure the git root directory is properly initialized
+ if (not FileSystemManager::CreateDirectory(StorageConfig::GitRoot())) {
+ Logger::Log(LogLevel::Error,
+ "Could not create directory {}. Aborting",
+ StorageConfig::GitRoot().string());
+ return false;
+ }
+ if (not GitRepo::InitAndOpen(StorageConfig::GitRoot(), true)) {
+ Logger::Log(LogLevel::Error,
+ fmt::format("could not initialize bare git repository {}",
+ StorageConfig::GitRoot().string()));
+ return false;
+ }
+
SourceTreeService sts{};
grpc::ServerBuilder builder;
builder.RegisterService(&sts);
+ // the user has not given any remote-execution endpoint
+ // so we start a "just-execute instance" on the same process
+ [[maybe_unused]] ExecutionServiceImpl es{};
+ [[maybe_unused]] ActionCacheServiceImpl ac{};
+ [[maybe_unused]] CASServiceImpl cas{};
+ [[maybe_unused]] BytestreamServiceImpl b{};
+ [[maybe_unused]] CapabilitiesServiceImpl cap{};
+ [[maybe_unused]] OperarationsServiceImpl op{};
+ if (with_execute) {
+ builder.RegisterService(&es)
+ .RegisterService(&ac)
+ .RegisterService(&cas)
+ .RegisterService(&b)
+ .RegisterService(&cap)
+ .RegisterService(&op);
+ }
+
std::shared_ptr<grpc::ServerCredentials> creds;
if (Auth::GetAuthMethod() == AuthMethod::kTLS) {
auto tls_opts = grpc::SslServerCredentialsOptions{};
@@ -69,20 +106,6 @@ auto ServeServerImpl::Run() -> bool {
creds = grpc::InsecureServerCredentials();
}
- // make sure the git root directory is properly initialized
- if (not FileSystemManager::CreateDirectory(StorageConfig::GitRoot())) {
- Logger::Log(LogLevel::Error,
- "Could not create directory {}. Aborting",
- StorageConfig::GitRoot().string());
- return false;
- }
- if (not GitRepo::InitAndOpen(StorageConfig::GitRoot(), true)) {
- Logger::Log(LogLevel::Error,
- fmt::format("could not initialize bare git repository {}",
- StorageConfig::GitRoot().string()));
- return false;
- }
-
builder.AddListeningPort(
fmt::format("{}:{}", interface_, port_), creds, &port_);
@@ -92,6 +115,13 @@ auto ServeServerImpl::Run() -> 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 = {
@@ -106,8 +136,10 @@ auto ServeServerImpl::Run() -> bool {
auto const& info_str = nlohmann::to_string(info);
Logger::Log(LogLevel::Info,
- fmt::format("{}serve service started: {}",
+ fmt::format("{}serve{} service{} started: {}",
Compatibility::IsCompatible() ? "compatible " : "",
+ with_execute ? " and execute" : "",
+ with_execute ? "s" : "",
info_str));
if (!info_file_.empty()) {
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 f756a104..494165ed 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
@@ -47,7 +47,7 @@ class ServeServerImpl {
ServeServerImpl(ServeServerImpl&&) noexcept = delete;
auto operator=(ServeServerImpl&&) noexcept -> ServeServerImpl& = delete;
- auto Run() -> bool;
+ auto Run(bool with_execute) -> bool;
~ServeServerImpl() = default;
private: