diff options
Diffstat (limited to 'zenserver/zenserver.cpp')
| -rw-r--r-- | zenserver/zenserver.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index 9a8090fc0..8b5ec79b6 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -12,13 +12,16 @@ #include <zencore/string.h> #include <zencore/thread.h> #include <zencore/timer.h> -#include <zencore/windows.h> #include <zenhttp/httpserver.h> #include <zenstore/basicfile.h> #include <zenstore/cas.h> #include <zenstore/cidstore.h> #include <zenutil/zenserverprocess.h> +#if ZEN_PLATFORM_WINDOWS +# include <zencore/windows.h> +#endif + #if ZEN_USE_MIMALLOC ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc-new-delete.h> @@ -138,7 +141,7 @@ namespace utils { if (!ErrorCode) { - for (const asio::ip::tcp::endpoint& Ep : Endpoints) + for (const asio::ip::tcp::endpoint Ep : Endpoints) { OutEndpoints.push_back("http://{}:{}"_format(Ep.address().to_string(), Ep.port())); } @@ -219,6 +222,7 @@ public: m_HttpProjectService.reset(new zen::HttpProjectService{*m_CidStore, m_ProjectStore}); m_LocalProjectService = zen::LocalProjectService::New(*m_CasStore, m_ProjectStore); +#if ZEN_WITH_COMPUTE_SERVICES ZEN_INFO("instantiating compute services"); std::filesystem::path SandboxDir = m_DataRoot / "exec" / "sandbox"; @@ -228,6 +232,7 @@ public: std::filesystem::path ApplySandboxDir = m_DataRoot / "exec" / "apply"; zen::CreateDirectories(ApplySandboxDir); m_HttpFunctionService = std::make_unique<zen::HttpFunctionService>(*m_CasStore, *m_CidStore, ApplySandboxDir); +#endif // ZEN_WITH_COMPUTE_SERVICES if (ServiceConfig.StructuredCacheEnabled) { @@ -265,6 +270,7 @@ public: m_Http->RegisterService(*m_StructuredCacheService); } +#if ZEN_WITH_COMPUTE_SERVICES if (m_HttpLaunchService) { m_Http->RegisterService(*m_HttpLaunchService); @@ -274,6 +280,7 @@ public: { m_Http->RegisterService(*m_HttpFunctionService); } +#endif // ZEN_WITH_COMPUTE_SERVICES m_FrontendService = std::make_unique<HttpFrontendService>(m_ContentRoot); @@ -323,7 +330,7 @@ public: if (m_DebugOptionForcedCrash) { - __debugbreak(); + ZEN_DEBUG_BREAK(); } const bool IsInteractiveMode = zen::IsInteractiveSession() && !m_TestMode; @@ -384,7 +391,7 @@ public: for (auto& PidEntry : m_ServerEntry->SponsorPids) { - if (uint32_t ThisPid = PidEntry.load(std::memory_order::memory_order_relaxed)) + if (uint32_t ThisPid = PidEntry.load(std::memory_order_relaxed)) { if (PidEntry.compare_exchange_strong(ThisPid, 0)) { @@ -503,13 +510,15 @@ private: 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::HttpHealthService m_HealthService; zen::Mesh m_ZenMesh{m_IoContext}; +#if ZEN_WITH_COMPUTE_SERVICES + std::unique_ptr<zen::HttpLaunchService> m_HttpLaunchService; std::unique_ptr<zen::HttpFunctionService> m_HttpFunctionService; +#endif std::unique_ptr<zen::HttpFrontendService> m_FrontendService; bool m_DebugOptionForcedCrash = false; @@ -733,6 +742,8 @@ ZenServer::InitializeStructuredCache(ZenServiceConfig& ServiceConfig) } // namespace zen +#if ZEN_PLATFORM_WINDOWS + class ZenWindowsService : public WindowsService { public: @@ -783,7 +794,7 @@ ZenWindowsService::Run() auto MakeLockData = [&] { CbObjectWriter Cbo; - Cbo << "pid" << _getpid() << "data" << ToUtf8(GlobalOptions.DataDir) << "port" << GlobalOptions.BasePort << "session_id" + Cbo << "pid" << zen::GetCurrentProcessId() << "data" << ToUtf8(GlobalOptions.DataDir) << "port" << GlobalOptions.BasePort << "session_id" << GetSessionId() << "ready" << IsReady; return Cbo.Save(); }; @@ -890,6 +901,10 @@ ZenWindowsService::Run() return 0; } +#endif // ZEN_PLATFORM_WINDOWS + +//////////////////////////////////////////////////////////////////////////////// + #if ZEN_WITH_TESTS int test_main(int argc, char** argv) @@ -927,6 +942,7 @@ main(int argc, char* argv[]) try { +#if ZEN_PLATFORM_WINDOWS ZenServerOptions GlobalOptions; ZenServiceConfig ServiceConfig; ParseGlobalCliOptions(argc, argv, GlobalOptions, ServiceConfig); @@ -937,7 +953,6 @@ main(int argc, char* argv[]) std::filesystem::create_directories(GlobalOptions.DataDir); } -#if ZEN_PLATFORM_WINDOWS if (GlobalOptions.InstallService) { WindowsService::Install(); @@ -951,10 +966,12 @@ main(int argc, char* argv[]) std::exit(0); } -#endif ZenWindowsService App(GlobalOptions, ServiceConfig); return App.ServiceMain(); +#else + return 1; +#endif } catch (std::exception& Ex) { |