aboutsummaryrefslogtreecommitdiff
path: root/zenserver/zenserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenserver/zenserver.cpp')
-rw-r--r--zenserver/zenserver.cpp53
1 files changed, 39 insertions, 14 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp
index b1989e1bc..e14f93f5b 100644
--- a/zenserver/zenserver.cpp
+++ b/zenserver/zenserver.cpp
@@ -43,7 +43,7 @@ ZEN_THIRD_PARTY_INCLUDES_END
# define BUILD_VERSION ("dev-build")
#endif
-#define ZEN_SCHEMA_VERSION 1
+#define ZEN_SCHEMA_VERSION 3 // Canged ZenCache manifest (per larsson)
//////////////////////////////////////////////////////////////////////////
// We don't have any doctest code in this file but this is needed to bring
@@ -214,18 +214,24 @@ public:
m_CasStore->Initialize(Config);
m_CidStore = std::make_unique<zen::CidStore>(*m_CasStore, m_DataRoot / "cid");
+ m_CasGc.SetCidStore(m_CidStore.get());
ZEN_INFO("instantiating project service");
- m_ProjectStore = new zen::ProjectStore(*m_CidStore, m_DataRoot / "projects");
+ m_ProjectStore = new zen::ProjectStore(*m_CidStore, m_DataRoot / "projects", m_CasGc);
m_HttpProjectService.reset(new zen::HttpProjectService{*m_CidStore, m_ProjectStore});
+
+#if ZEN_USE_NAMED_PIPES
m_LocalProjectService = zen::LocalProjectService::New(*m_CasStore, m_ProjectStore);
+#endif
ZEN_INFO("instantiating compute services");
+#if ZEN_USE_EXEC
std::filesystem::path SandboxDir = m_DataRoot / "exec" / "sandbox";
zen::CreateDirectories(SandboxDir);
m_HttpLaunchService = std::make_unique<zen::HttpLaunchService>(*m_CasStore, SandboxDir);
+#endif
std::filesystem::path ApplySandboxDir = m_DataRoot / "exec" / "apply";
zen::CreateDirectories(ApplySandboxDir);
@@ -267,10 +273,12 @@ public:
m_Http->RegisterService(*m_StructuredCacheService);
}
+#if ZEN_USE_EXEC
if (m_HttpLaunchService)
{
m_Http->RegisterService(*m_HttpLaunchService);
}
+#endif
if (m_HttpFunctionService)
{
@@ -283,6 +291,16 @@ public:
{
m_Http->RegisterService(*m_FrontendService);
}
+
+ ZEN_INFO("initializing GC, enabled '{}', interval {}s", ServerOptions.GcConfig.Enabled, ServerOptions.GcConfig.IntervalSeconds);
+ zen::GcSchedulerConfig GcConfig{
+ .RootDirectory = m_DataRoot / "gc",
+ .Interval = std::chrono::seconds(ServerOptions.GcConfig.IntervalSeconds),
+ .MaxCacheDuration = std::chrono::seconds(ServerOptions.GcConfig.Cache.MaxDurationSeconds),
+ .CollectSmallObjects = ServerOptions.GcConfig.CollectSmallObjects,
+ .Enabled = ServerOptions.GcConfig.Enabled,
+ };
+ m_GcScheduler.Initialize(GcConfig);
}
void InitializeState(const ZenServerOptions& ServerOptions);
@@ -495,25 +513,32 @@ private:
zen::Ref<zen::HttpServer> m_Http;
zen::HttpStatusService m_StatusService;
zen::HttpStatsService m_StatsService;
- std::unique_ptr<zen::CasStore> m_CasStore{zen::CreateCasStore()};
+ zen::CasGc m_CasGc;
+ zen::GcScheduler m_GcScheduler{m_CasGc};
+ std::unique_ptr<zen::CasStore> m_CasStore{zen::CreateCasStore(m_CasGc)};
std::unique_ptr<zen::CidStore> m_CidStore;
std::unique_ptr<zen::ZenCacheStore> m_CacheStore;
- zen::CasGc m_Gc{*m_CasStore};
zen::CasScrubber m_Scrubber{*m_CasStore};
zen::HttpTestService m_TestService;
zen::HttpTestingService m_TestingService;
zen::HttpCasService m_CasService{*m_CasStore};
zen::RefPtr<zen::ProjectStore> m_ProjectStore;
- zen::Ref<zen::LocalProjectService> m_LocalProjectService;
- std::unique_ptr<zen::HttpLaunchService> m_HttpLaunchService;
std::unique_ptr<zen::HttpProjectService> m_HttpProjectService;
std::unique_ptr<zen::HttpStructuredCacheService> m_StructuredCacheService;
- zen::HttpAdminService m_AdminService;
+ zen::HttpAdminService m_AdminService{m_GcScheduler};
zen::HttpHealthService m_HealthService;
zen::Mesh m_ZenMesh{m_IoContext};
std::unique_ptr<zen::HttpFunctionService> m_HttpFunctionService;
std::unique_ptr<zen::HttpFrontendService> m_FrontendService;
+#if ZEN_USE_EXEC
+ std::unique_ptr<zen::HttpLaunchService> m_HttpLaunchService;
+#endif
+
+#if ZEN_USE_NAMED_PIPES
+ zen::Ref<zen::LocalProjectService> m_LocalProjectService;
+#endif
+
bool m_DebugOptionForcedCrash = false;
};
@@ -580,6 +605,9 @@ ZenServer::InitializeState(const ZenServerOptions& ServerOptions)
}
}
+ // Release any open handles so we can overwrite the manifest
+ ManifestData = {};
+
// Handle any state wipe
if (WipeState)
@@ -629,7 +657,7 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
auto ValueOrDefault = [](std::string_view Value, std::string_view Default) { return Value.empty() ? Default : Value; };
ZEN_INFO("instantiating structured cache service");
- m_CacheStore = std::make_unique<ZenCacheStore>(m_DataRoot / "cache");
+ m_CacheStore = std::make_unique<ZenCacheStore>(m_CasGc, m_DataRoot / "cache");
std::unique_ptr<zen::UpstreamCache> UpstreamCache;
if (ServerOptions.UpstreamCacheConfig.CachePolicy != UpstreamCachePolicy::Disabled)
@@ -734,12 +762,8 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions)
}
}
- m_StructuredCacheService.reset(new zen::HttpStructuredCacheService(*m_CacheStore,
- *m_CasStore,
- *m_CidStore,
- m_StatsService,
- m_StatusService,
- std::move(UpstreamCache)));
+ m_StructuredCacheService.reset(
+ new zen::HttpStructuredCacheService(*m_CacheStore, *m_CidStore, m_StatsService, m_StatusService, std::move(UpstreamCache)));
}
} // namespace zen
@@ -896,6 +920,7 @@ test_main(int argc, char** argv)
zen::zencore_forcelinktests();
zen::zenhttp_forcelinktests();
zen::zenstore_forcelinktests();
+ zen::z$_forcelink();
zen::logging::InitializeLogging();