]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Fix runSalome.py --logger
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 16:04:44 +0000 (17:04 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 18 Feb 2022 16:04:44 +0000 (17:04 +0100)
bin/server.py
src/SALOMETraceCollector/CMakeLists.txt
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx

index 2d30b82ba856c757c2c17f5b47cbf89bd1f013ef..8bbe120518264a1d7612851411595ed0f0253beb 100644 (file)
@@ -24,6 +24,7 @@
 import os, sys, string
 from salome_utils import getHostName
 process_id = {}
+import logging
 
 # -----------------------------------------------------------------------------
 #
@@ -70,6 +71,11 @@ class Server:
                                    + os.getenv("LD_LIBRARY_PATH")]
               myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path
         command = myargs + self.CMD
+        for sapcfg in ["SalomeAppSLConfig","SalomeAppConfig"]:
+          if sapcfg in os.environ:
+            logging.getLogger().debug("{}={}".format(sapcfg,os.environ[sapcfg]))
+        command1 = (" ".join(command)).replace("(","\\\(") ; command1 = command1.replace(")","\\\)")
+        logging.getLogger().debug("Command to be launched : {}".format(command1))
         # print("command = ", command)
         if sys.platform == "win32":
           import subprocess
@@ -86,6 +92,7 @@ class Server:
           #store process pid if it really exists
           process_id[pid]=self.CMD
         self.PID = pid
+        logging.getLogger().debug("PID of launched command : {}".format(pid))
         return pid
 
     def daemonize(self,args):
index ba6acb9b738466295d4f3d2fe5de6f567fb430b9..4ce179f9ab1f131f05e7f486983fab4fdc4a0cb4 100644 (file)
@@ -25,6 +25,8 @@ INCLUDE_DIRECTORIES(
   ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
   ${CMAKE_CURRENT_SOURCE_DIR}/../Utils
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace
+  ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
+  ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
   ${PROJECT_BINARY_DIR}/idl
 )
 
index 3320bdfb9c1e40636da22badba4b7a536d229c29..ce2ccd4e986bd91b27f35a113d42da6d54d046e6 100644 (file)
 //  $Header$
 //
 #include "TraceCollector_WaitForServerReadiness.hxx"
+#include "KernelBasis.hxx"
+#include "SALOME_Fake_NamingService.hxx"
 #include "OpUtil.hxx"
 #include <iostream>
 #include <ctime>
+#include <memory>
 
 
 #if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1900
@@ -68,60 +71,78 @@ CORBA::Object_ptr TraceCollector_WaitForServerReadiness(const std::string& serve
       // NB. You can't use SALOME_NamingService class because
       // it uses MESSAGE macro
       // Otherwise, you will get segmentation fault.   
-
-      CosNaming::NamingContext_var inc;
-      CosNaming::Name name;
-      name.length(1);
-      name[0].id = CORBA::string_dup(serverName.c_str());
-      CORBA::Object_var theObj=CORBA::Object::_nil();
-
-      for (int itry=0; itry < NumberOfTries; itry++)
+      if(getSSLMode())
+      {
+        std::string regName(std::string("/")+serverName);
+        std::unique_ptr<SALOME_Fake_NamingService> ns(new SALOME_Fake_NamingService);
+        for (int itry=0; itry < NumberOfTries; itry++)
         {
-          try
-            { 
-              if(!CORBA::is_nil(orb)) 
-                theObj = orb->resolve_initial_references("NameService");
-              if (!CORBA::is_nil(theObj))
-                inc = CosNaming::NamingContext::_narrow(theObj);
-            }  
-          catch( CORBA::SystemException& )
-            {
-              std::cout << "TraceCollector_WaitForServerReadiness: "
-                   << "CORBA::SystemException: "
-                   << "Unable to contact the Naming Service" << std::endl;
-            }
-          catch(...)
-            {
-              std::cout << "TraceCollector_WaitForServerReadiness: "
-                   << "Unknown exception dealing with Naming Service" << std::endl;
-            }
-          
-          obj=CORBA::Object::_nil();
-          if(!CORBA::is_nil(inc))
-            {
-              try
-                {
-                  obj = inc->resolve(name);
-                  if (!CORBA::is_nil(obj))
-                    {
-                      //cout << "TraceCollector_WaitForServerReadiness: "
-                      //           << serverName << " found in CORBA Name Service" << endl;
-                      break;
-                    }
-                }
-              catch (const CosNaming::NamingContext::NotFound&)
-                {
-                  std::cout << "Caught exception: Naming Service can't found Logger";
-                }
-            }
-#ifndef WIN32
-          nanosleep(&ts_req,&ts_rem);
-#else
-          Sleep(TIMESleep / 1000000);
-#endif
-                 std::cout << "TraceCollector_WaitForServerReadiness: retry look for"
-               << serverName << std::endl;
-        }          
+          obj = ns->Resolve(regName.c_str());
+          if(!CORBA::is_nil(obj))
+            break;
+  #ifndef WIN32
+            nanosleep(&ts_req,&ts_rem);
+  #else
+            Sleep(TIMESleep / 1000000);
+  #endif
+        }
+      }
+      else
+      {
+        CosNaming::NamingContext_var inc;
+        CosNaming::Name name;
+        name.length(1);
+        name[0].id = CORBA::string_dup(serverName.c_str());
+        CORBA::Object_var theObj=CORBA::Object::_nil();
+
+        for (int itry=0; itry < NumberOfTries; itry++)
+          {
+            try
+              { 
+                if(!CORBA::is_nil(orb)) 
+                  theObj = orb->resolve_initial_references("NameService");
+                if (!CORBA::is_nil(theObj))
+                  inc = CosNaming::NamingContext::_narrow(theObj);
+              }  
+            catch( CORBA::SystemException& )
+              {
+                std::cout << "TraceCollector_WaitForServerReadiness: "
+                    << "CORBA::SystemException: "
+                    << "Unable to contact the Naming Service" << std::endl;
+              }
+            catch(...)
+              {
+                std::cout << "TraceCollector_WaitForServerReadiness: "
+                    << "Unknown exception dealing with Naming Service" << std::endl;
+              }
+            
+            obj=CORBA::Object::_nil();
+            if(!CORBA::is_nil(inc))
+              {
+                try
+                  {
+                    obj = inc->resolve(name);
+                    if (!CORBA::is_nil(obj))
+                      {
+                        //cout << "TraceCollector_WaitForServerReadiness: "
+                        //           << serverName << " found in CORBA Name Service" << endl;
+                        break;
+                      }
+                  }
+                catch (const CosNaming::NamingContext::NotFound&)
+                  {
+                    std::cout << "Caught exception: Naming Service can't found Logger";
+                  }
+              }
+  #ifndef WIN32
+            nanosleep(&ts_req,&ts_rem);
+  #else
+            Sleep(TIMESleep / 1000000);
+  #endif
+        std::cout << "TraceCollector_WaitForServerReadiness: retry look for"
+                << serverName << std::endl;
+          }
+      }       
     }
   catch (const CosNaming::NamingContext::NotFound&)
     {