]> 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>
Mon, 21 Feb 2022 08:38:02 +0000 (09:38 +0100)
Fix runSalome.py --forground=1 [dft]

13 files changed:
bin/killSalomeWithPort.py
bin/runSalome.py
bin/runSalomeCommon.py
bin/server.py
src/KERNEL_PY/__init__.py
src/Logger/CMakeLists.txt
src/Logger/KernelLogger.cxx [new file with mode: 0644]
src/Logger/KernelLogger.hxx [new file with mode: 0644]
src/Logger/KernelLogger.i [new file with mode: 0644]
src/Logger/SALOME_Logger_Server.cxx
src/Logger/SALOME_Logger_Server.hxx
src/SALOMETraceCollector/CMakeLists.txt
src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx

index 59a6c2b93e5c3292be19191a1d2f20a0b31ca89d..5375452df8317cebcae2b9639e7902b7c21d9042 100755 (executable)
@@ -302,6 +302,38 @@ def __guessPiDictFilename(port):
 
     return None
 
+def killMyPortSSL(*ports):
+    """ Called by runSalome.py after CTRL-C"""
+    for port in ports:
+        # ensure port is an integer
+        with suppress(ValueError):
+            port = int(port)
+
+        with suppress(Exception):
+            # DO NOT REMOVE NEXT LINE: it tests PortManager availability!
+            from PortManager import releasePort
+            # get pidict file
+            filedict = getPiDict(port)
+            if not osp.isfile(filedict): # removed by previous call, see (1) above
+                if verbose():
+                    print("SALOME session on port {} is already stopped".format(port))
+                # remove port from PortManager config file
+                with suppress(ImportError):
+                    if verbose():
+                        print("Removing port from PortManager configuration file")
+                    releasePort(port)
+                return
+        try:
+            # DO NOT REMOVE NEXT LINE: it tests PortManager availability!
+            import PortManager # pragma pylint: disable=unused-import
+            for file_path in glob('{}*'.format(getPiDict(port))):
+                __killMyPort(port, file_path)
+        except ImportError:
+            __killMyPort(port, __guessPiDictFilename(port))
+
+        # clear-up omniOrb config files
+        appliCleanOmniOrbConfig(port)
+
 def killMyPort(*ports):
     """
     Kill SALOME session running on the specified port.
index bd0a5bcaf78337638de4a13ee3cf354f4869044b..20f3da436b1fa1d6a045127e41e817b75454255f 100755 (executable)
@@ -70,6 +70,8 @@ def startSalome(args, modules_list, modules_root_dir):
 
     logger.debug("startSalome : {} ".format(args))
 
+    ior_fakens_filename = None
+
     # Launch  Session Server (to show splash ASAP)
     #
 
@@ -77,6 +79,7 @@ def startSalome(args, modules_list, modules_root_dir):
         mySessionServ = runSalomeNoServer.NoSessionServer(args,args['modules'],modules_root_dir)
         mySessionServ.setpath(modules_list,modules_root_dir)
         mySessionServ.run()
+        ior_fakens_filename = mySessionServ.iorfakens
     
     end_time = os.times()
 
@@ -96,14 +99,13 @@ def startSalome(args, modules_list, modules_root_dir):
     except Exception:
         import traceback
         traceback.print_exc()
-        print("-------------------------------------------------------------")
-        print("-- to get an external python interpreter:runSalome --interp=1")
-        print("-------------------------------------------------------------")
+        logger.error("-------------------------------------------------------------")
+        logger.error("-- to get an external python interpreter:runSalome --interp=1")
+        logger.error("-------------------------------------------------------------")
 
     logger.debug("additional external python interpreters: {}".format(nbaddi))
     if nbaddi:
         for i in range(nbaddi):
-            print("i=",i)
             anInterp=InterpServer(args)
             anInterp.run()
 
@@ -115,7 +117,7 @@ def startSalome(args, modules_list, modules_root_dir):
         except ImportError:
             pass
 
-    return
+    return ior_fakens_filename
 
 # -----------------------------------------------------------------------------
 
@@ -126,15 +128,13 @@ def useSalome(args, modules_list, modules_root_dir):
     show registered objects in Naming Service.
     """
     global process_id
-
+    ior_fakens_filename = None
     try:
-        startSalome(args, modules_list, modules_root_dir)
+        ior_fakens_filename = startSalome(args, modules_list, modules_root_dir)
     except Exception:
         import traceback
         traceback.print_exc()
-        print()
-        print()
-        print("--- Error during Salome launch ---")
+        logger.error("--- Error during Salome launch ---")
 
     # print(process_id)
 
@@ -160,7 +160,7 @@ def useSalome(args, modules_list, modules_root_dir):
     the processes resulting from the previous execution.
     """%filedict)
 
-    return
+    return ior_fakens_filename
 
 def execScript(script_path):
     print('executing', script_path)
@@ -186,35 +186,66 @@ def main(exeName=None):
     kill_salome(args)
     # --
     setenv.set_env(args, modules_list, modules_root_dir, keepEnvironment=keep_env)
-    useSalome(args, modules_list, modules_root_dir)
-    return args
+    ior_fakens_filename = useSalome(args, modules_list, modules_root_dir)
+    return args, ior_fakens_filename
 
 # -----------------------------------------------------------------------------
 
-def foreGround(args):
+def foreGround(args, ior_fakens_filename):
     # --
-    if "session_object" not in args:
+    import os
+    gui_detected = False
+    dt = 0.1
+    nbtot = 100
+    nb = 0
+    if ior_fakens_filename is None:
+        logger.warn("No file set to host IOR of the fake naming server")
+        return
+    if not os.path.exists(ior_fakens_filename):
+        logger.warn("No file {} set to host IOR of the fake naming server does not exit !")
         return
-    session = args["session_object"]
+    import CORBA
+    import Engines
+    import SALOME
+    from time import sleep
+    orb = CORBA.ORB_init([''], CORBA.ORB_ID)
+    ior_fakens = None
+    session = None
+    while True:
+        try:
+            ior_fakens = orb.string_to_object(open(ior_fakens_filename).read())
+            session = orb.string_to_object(ior_fakens.Resolve("/Kernel/Session").decode())
+        except Exception:
+            pass
+        if ( session is not None ) and (not CORBA.is_nil(session)):
+            try:
+                os.remove(ior_fakens_filename)
+                logger.debug("File {} has been removed".format(ior_fakens_filename))
+            except:
+                pass
+            logger.debug("Session in child process has been found ! yeah ! {}".format(str(session)))
+            break
+        sleep(dt)
+        nb += 1
+        logger.debug("Unfortunately Session not found into {} : Sleep and retry. {}/{}".format(ior_fakens_filename,nb,nbtot))
+        if nb == nbtot:
+            break
+    nb = 0
     # --
     # Wait until gui is arrived
     # tmax = nbtot * dt
     # --
-    gui_detected = False
-    dt = 0.1
-    nbtot = 100
-    nb = 0
     session_pid = None
     while 1:
         try:
             status = session.GetStatSession()
             gui_detected = status.activeGUI
             session_pid = session.getPID()
+            logger.debug("Process of the session under monitoring {}".format(session_pid))
         except Exception:
             pass
         if gui_detected:
             break
-        from time import sleep
         sleep(dt)
         nb += 1
         if nb == nbtot:
@@ -248,14 +279,14 @@ def foreGround(args):
             pass
         pass
     except KeyboardInterrupt:
-        from killSalomeWithPort import killMyPort
-        killMyPort(port)
+        from killSalomeWithPort import killMyPortSSL
+        killMyPortSSL(port)
         pass
     return
 #
 
 def runSalome():
-    args = main()
+    args, ior_fakens_filename = main()
     # --
     test = args['gui'] and args['session_gui']
     test = test or args['wake_up_session']
@@ -279,7 +310,7 @@ def runSalome():
     if test:
         from time import sleep
         sleep(3.0)
-        foreGround(args)
+        foreGround(args, ior_fakens_filename)
         pass
     pass
 #
index 1e3295a7e77166142f0a52fad9b7aa7cb1550984..354017404be16e9cf52751a3dcb3d4ff699482c8 100755 (executable)
@@ -242,6 +242,7 @@ class LoggerServer(Server):
 
 # ---
 import abc
+import tempfile
 class CommonSessionServer(Server):
     def __init__(self,args,modules_list,modules_root_dir):
         self.args = args.copy()
@@ -321,6 +322,11 @@ class CommonSessionServer(Server):
             pass
         if 'language' in self.args:
             self.SCMD2+=['--language=%s' % self.args['language']]
+        tempfile.mkstemp()
+        os_handle, iorfakens = tempfile.mkstemp()
+        self.iorfakens = iorfakens
+        os.close(os_handle)
+        self.SCMD2+=["--iorfakens={}".format(iorfakens)]
         pass
 
     @abc.abstractmethod
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 175a86c30c6d2dd16e1af1d1affe5ddb60bc39f9..d2be57dfc30154a84127bf78a2d12c67f7a4737a 100644 (file)
@@ -173,11 +173,14 @@ def withServers():
     import KernelBasis
     KernelBasis.setSSLMode(False)
 
-def salome_init(path=None, embedded=False):
+def salome_init(path=None, embedded=False, iorfakensfile=None):
+    """
+    :param iorfakensfile: filename inside which IOR of fake NS will be written
+    """
     import KernelBasis
     if KernelBasis.getSSLMode():
         if KernelBasis.getIOROfEmbeddedNS() == "":
-            salome_init_without_session(path, embedded)
+            salome_init_without_session(path, embedded, iorfakensfile)
         else:
             salome_init_without_session_attached(path, embedded)
     else:
@@ -220,7 +223,7 @@ def salome_init_without_session_common(path=None, embedded=False):
     from NamingService import NamingService
     naming_service = NamingService()
 
-def salome_init_without_session(path=None, embedded=False):
+def salome_init_without_session(path=None, embedded=False, iorfakensfile=None):
     salome_init_without_session_common(path,embedded)
     global lcc,cm,dsm,esm
     import KernelLauncher
@@ -241,6 +244,14 @@ def salome_init_without_session(path=None, embedded=False):
     # esm inherits from SALOME_CPythonHelper singleton already initialized by GetDSMInstance
     # esm inherits also from SALOME_ResourcesManager creation/initialization (concerning SingleThreadPOA POA) when KernelLauncher.GetContainerManager() has been called
     esm = KernelLauncher.GetExternalServer()
+    #
+    import KernelLogger
+    naming_service.Register(KernelLogger.myLogger(),"/Logger")
+    #
+    from NamingService import NamingService
+    if iorfakensfile is not None:
+        with open(iorfakensfile,"w") as iorfakensf:
+            iorfakensf.write(NamingService.IOROfNS())
     
 def salome_init_without_session_attached(path=None, embedded=False):
     """
index 5a32c47ad7d9569ebf633ad1c8647c42e92f98ea..5b74e794c5aedc01749d46d12f3444274bf28155 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+include(${SWIG_USE_FILE})
+
 INCLUDE_DIRECTORIES(
   ${OMNIORB_INCLUDE_DIR}
   ${PTHREAD_INCLUDE_DIR}
+  ${PYTHON_INCLUDE_DIRS}
   ${PROJECT_BINARY_DIR}/salome_adm
   ${CMAKE_CURRENT_SOURCE_DIR}/../ArgvKeeper
   ${CMAKE_CURRENT_SOURCE_DIR}/../Basics
   ${CMAKE_CURRENT_SOURCE_DIR}/../SALOMELocalTrace
   ${CMAKE_CURRENT_SOURCE_DIR}/../Utils
+  ${CMAKE_CURRENT_SOURCE_DIR}/../KernelHelpers
+  ${CMAKE_CURRENT_SOURCE_DIR}/../NamingService
+  ${CMAKE_CURRENT_SOURCE_DIR}/../LifeCycleCORBA
+  ${CMAKE_CURRENT_SOURCE_DIR}
   ${PROJECT_BINARY_DIR}/idl
 )
 ADD_DEFINITIONS(${OMNIORB_DEFINITIONS})
 
 ADD_LIBRARY(SalomeLoggerServer SALOME_Trace.cxx SALOME_Logger_Server.cxx)
-TARGET_LINK_LIBRARIES(SalomeLoggerServer SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PLATFORM_LIBS})
+TARGET_LINK_LIBRARIES(SalomeLoggerServer SalomeKernelHelpers  SalomeIDLKernel ${OMNIORB_LIBRARIES} ${PLATFORM_LIBS})
 INSTALL(TARGETS SalomeLoggerServer EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 SET(SALOME_Logger_Server_SOURCES
@@ -43,6 +50,7 @@ SET(SALOME_Logger_Server_LIBS
   SalomeLoggerServer
   SalomeIDLKernel
   OpUtil
+  SalomeKernelHelpers
   ${OMNIORB_LIBRARIES}
 )
 
@@ -50,6 +58,25 @@ ADD_EXECUTABLE(SALOME_Logger_Server ${SALOME_Logger_Server_SOURCES})
 TARGET_LINK_LIBRARIES(SALOME_Logger_Server ${SALOME_Logger_Server_LIBS})
 INSTALL(TARGETS SALOME_Logger_Server EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS})
 
+SET(KernelLogger_HEADERS KernelLogger.hxx KernelLogger.i)
+SET(KernelLogger_SOURCES KernelLogger.cxx ${KernelLogger_HEADERS})
+SET_SOURCE_FILES_PROPERTIES(KernelLogger.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(KernelLogger.i PROPERTIES SWIG_FLAGS "-py3")
+SET_SOURCE_FILES_PROPERTIES(KernelLogger_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H")
+SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/KernelLogger.py )
+IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") 
+  SWIG_ADD_MODULE(KernelLogger python ${KernelLogger_SOURCES})
+ELSE()
+  SWIG_ADD_LIBRARY(KernelLogger LANGUAGE python SOURCES ${KernelLogger_SOURCES})
+ENDIF()
+IF(${MACHINE} STREQUAL WINDOWS)
+  SET_TARGET_PROPERTIES(_KernelLogger PROPERTIES DEBUG_OUTPUT_NAME _KernelLogger_d)
+ENDIF(${MACHINE} STREQUAL WINDOWS)
+SWIG_LINK_LIBRARIES(KernelLogger ${PYTHON_LIBRARIES} ${PLATFORM_LIBS} SalomeLoggerServer)
+install(TARGETS _KernelLogger DESTINATION ${SALOME_INSTALL_LIBS})
+install(FILES ${KernelLogger_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
+SALOME_INSTALL_SCRIPTS("${_swig_SCRIPTS}"  ${SALOME_INSTALL_BINS} EXTRA_DPYS "${SWIG_MODULE_KernelLogger_REAL_NAME}")
+
 # Executable scripts to be installed
 SALOME_INSTALL_SCRIPTS(SALOME_Trace.py ${SALOME_INSTALL_SCRIPT_PYTHON})
 
diff --git a/src/Logger/KernelLogger.cxx b/src/Logger/KernelLogger.cxx
new file mode 100644 (file)
index 0000000..fdc4b9a
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright (C) 2021  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "KernelLogger.hxx"
+#include "SALOME_Logger_Server.hxx"
+#include "SALOME_KernelServices.hxx"
+
+std::string GetLoggerInstance()
+{
+  SALOME_Logger::Logger_var study = KERNEL::getLoggerServantSA();
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  CORBA::String_var ior = orb->object_to_string(study);
+  return std::string(ior.in());
+}
diff --git a/src/Logger/KernelLogger.hxx b/src/Logger/KernelLogger.hxx
new file mode 100644 (file)
index 0000000..acc216b
--- /dev/null
@@ -0,0 +1,24 @@
+// Copyright (C) 2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include <string>
+
+std::string GetLoggerInstance();
diff --git a/src/Logger/KernelLogger.i b/src/Logger/KernelLogger.i
new file mode 100644 (file)
index 0000000..068a7f8
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright (C) 2022  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+%module KernelLogger
+
+%include "std_string.i"
+
+%{
+#include "KernelLogger.hxx"
+%}
+
+%inline
+{
+  std::string GetLoggerInstance();
+}
+
+%pythoncode %{
+def myLogger():
+  import SALOME_Logger
+  import CORBA
+  orb=CORBA.ORB_init([''])
+  return orb.string_to_object(GetLoggerInstance())
+%}
index 05751ac9763718dfcd5384128c48299c7f0fd4f6..3fda427410c5b13b82328fc5357ac971c371f6b6 100644 (file)
@@ -27,6 +27,7 @@
 //
 #include <iostream>
 #include "SALOME_Logger_Server.hxx"
+#include "SALOME_KernelServices.hxx"
 #include <SALOMEconfig.h>
 #include <sys/types.h>
 #ifndef WIN32
 
 omni_mutex Logger::myLock;
 
+SALOME_Logger::Logger_ptr KERNEL::getLoggerServantSA()
+{
+  CORBA::ORB_ptr orb = KERNEL::getORB();
+  CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+  PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+  Logger *servant = new Logger;
+  SALOME_Logger::Logger_ptr logger = servant->_this();
+  servant->_remove_ref();
+  return logger;
+}
+
 /////////////////////////////////////////////////////////////////////
 // Construction/Destruction
 //////////////////////////////////////////////////////////////////////
index 07615ccb7d1e9b17ab600505e22a90cac9f2dcce..7377d7696b4de2ffd899597b0ef8b468a7fd382b 100644 (file)
 #pragma warning(disable:4275) // Disable warning interface non dll
 #endif
 
+namespace KERNEL
+{
+  SALOME_Logger::Logger_ptr getLoggerServantSA();
+}
+
 class LOGGER_EXPORT Logger :
   public POA_SALOME_Logger::Logger
 {
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&)
     {