Pārlūkot izejas kodu

HPCC-23502 Add a way to test whether running in containerized mode

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 gadi atpakaļ
vecāks
revīzija
06d9ea42c1
3 mainītis faili ar 12 papildinājumiem un 1 dzēšanām
  1. 1 1
      dockerfiles/platform-core/Dockerfile
  2. 10 0
      system/jlib/jutil.cpp
  3. 1 0
      system/jlib/jutil.hpp

+ 1 - 1
dockerfiles/platform-core/Dockerfile

@@ -38,4 +38,4 @@ RUN dpkg -i *.deb ; \
 
 USER hpcc
 ENV PATH="/opt/HPCCSystems/bin:${PATH}"
-
+ENV HPCC_containerized=1

+ 10 - 0
system/jlib/jutil.cpp

@@ -1692,6 +1692,16 @@ void doStackProbe()
 #pragma GCC diagnostic pop
 #endif
 
+extern jlib_decl bool isCloud()
+{
+    static bool cloudy = []()
+        {
+            const char *env = getenv("HPCC_containerized");
+            return (env && atoi(env)==1);
+        }();
+    return cloudy;
+}
+
 #ifdef _WIN32
 
 DWORD dwTlsIndex = -1;

+ 1 - 0
system/jlib/jutil.hpp

@@ -249,6 +249,7 @@ extern jlib_decl unsigned msTick();
 extern jlib_decl unsigned usTick();
 extern jlib_decl int write_pidfile(const char * instance);
 extern jlib_decl void doStackProbe();
+extern jlib_decl bool isCloud();
 
 #ifndef arraysize
 #define arraysize(T) (sizeof(T)/sizeof(*T))