diff options
| author | Stefan Boberg <[email protected]> | 2021-09-17 23:18:20 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-17 23:18:48 +0200 |
| commit | 0ee89539ead8631b02953ddf601770aefa557edb (patch) | |
| tree | ef2e09d747bb3d7497507362bda560b905d478d6 /zenhttp | |
| parent | Added IsInteractiveSession() query to help identify if the process is running... (diff) | |
| download | zen-0ee89539ead8631b02953ddf601770aefa557edb.tar.xz zen-0ee89539ead8631b02953ddf601770aefa557edb.zip | |
zenserver can now run as a Windows service. We'll still need to improve how data files are found as the current defaults are relative to the user directory which ends up being in the Windows folder when running as the local system user
Diffstat (limited to 'zenhttp')
| -rw-r--r-- | zenhttp/httpnull.cpp | 4 | ||||
| -rw-r--r-- | zenhttp/httpnull.h | 2 | ||||
| -rw-r--r-- | zenhttp/httpsys.cpp | 23 | ||||
| -rw-r--r-- | zenhttp/httpuws.cpp | 4 | ||||
| -rw-r--r-- | zenhttp/httpuws.h | 2 | ||||
| -rw-r--r-- | zenhttp/include/zenhttp/httpserver.h | 2 |
6 files changed, 21 insertions, 16 deletions
diff --git a/zenhttp/httpnull.cpp b/zenhttp/httpnull.cpp index 57cba13d3..e49051ac5 100644 --- a/zenhttp/httpnull.cpp +++ b/zenhttp/httpnull.cpp @@ -28,8 +28,10 @@ HttpNullServer::Initialize(int BasePort) } void -HttpNullServer::Run(bool TestMode) +HttpNullServer::Run(bool IsInteractiveSession) { + const bool TestMode = !IsInteractiveSession; + if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Press ESC or Q to quit"); diff --git a/zenhttp/httpnull.h b/zenhttp/httpnull.h index b15b1b123..867bbe4d2 100644 --- a/zenhttp/httpnull.h +++ b/zenhttp/httpnull.h @@ -19,7 +19,7 @@ public: virtual void RegisterService(HttpService& Service) override; virtual void Initialize(int BasePort) override; - virtual void Run(bool TestMode) override; + virtual void Run(bool IsInteractiveSession) override; virtual void RequestExit() override; private: diff --git a/zenhttp/httpsys.cpp b/zenhttp/httpsys.cpp index c2d4ef14c..b5313021c 100644 --- a/zenhttp/httpsys.cpp +++ b/zenhttp/httpsys.cpp @@ -707,29 +707,30 @@ HttpSysServer::StartServer() } void -HttpSysServer::Run(bool TestMode) +HttpSysServer::Run(bool IsInteractive) { - if (TestMode == false) + if (IsInteractive) { zen::logging::ConsoleLog().info("Zen Server running. Press ESC or Q to quit"); } do { - int WaitTimeout = -1; + //int WaitTimeout = -1; + int WaitTimeout = 100; - if (!TestMode) + if (IsInteractive) { WaitTimeout = 1000; - } - - if (!TestMode && _kbhit() != 0) - { - char c = (char)_getch(); - if (c == 27 || c == 'Q' || c == 'q') + if (_kbhit() != 0) { - RequestApplicationExit(0); + char c = (char)_getch(); + + if (c == 27 || c == 'Q' || c == 'q') + { + RequestApplicationExit(0); + } } } diff --git a/zenhttp/httpuws.cpp b/zenhttp/httpuws.cpp index 992809b17..e062e7747 100644 --- a/zenhttp/httpuws.cpp +++ b/zenhttp/httpuws.cpp @@ -37,8 +37,10 @@ HttpUwsServer::Initialize(int BasePort) } void -HttpUwsServer::Run(bool TestMode) +HttpUwsServer::Run(bool IsInteractive) { + const bool TestMode = !IsInteractive; + if (TestMode == false) { zen::logging::ConsoleLog().info("Zen Server running (null HTTP). Press ESC or Q to quit"); diff --git a/zenhttp/httpuws.h b/zenhttp/httpuws.h index ec55ae2fd..5e300202f 100644 --- a/zenhttp/httpuws.h +++ b/zenhttp/httpuws.h @@ -16,7 +16,7 @@ public: virtual void RegisterService(HttpService& Service) override; virtual void Initialize(int BasePort) override; - virtual void Run(bool TestMode) override; + virtual void Run(bool IsInteractiveSession) override; virtual void RequestExit() override; private: diff --git a/zenhttp/include/zenhttp/httpserver.h b/zenhttp/include/zenhttp/httpserver.h index ed6075c92..6a7dc8a70 100644 --- a/zenhttp/include/zenhttp/httpserver.h +++ b/zenhttp/include/zenhttp/httpserver.h @@ -167,7 +167,7 @@ class HttpServer : public RefCounted public: virtual void RegisterService(HttpService& Service) = 0; virtual void Initialize(int BasePort) = 0; - virtual void Run(bool TestMode) = 0; + virtual void Run(bool IsInteractiveSession) = 0; virtual void RequestExit() = 0; }; |