1 // Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SALOME Container : implementation of container and engine for Kernel
24 // File : SALOME_Container.cxx
25 // Author : Paul RASCLE, EDF - MARC TAJCHMAN, CEA
38 #include "SALOME_Container_i.hxx"
39 #include "utilities.h"
40 #include "Utils_ORB_INIT.hxx"
41 #include "Utils_SINGLETON.hxx"
42 #include "SALOMETraceCollector.hxx"
46 #include <Utils_Timer.hxx>
62 #include "Container_init_python.hxx"
66 extern "C" void HandleServerSideSignals(CORBA::ORB_ptr theORB);
69 #if PY_VERSION_HEX < 0x03050000
71 Py_DecodeLocale(const char *arg, size_t *size)
73 return _Py_char2wchar(arg, size);
77 int main(int argc, char* argv[])
80 MPI_Init(&argc,&argv);
83 // Initialise the ORB.
84 //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
85 //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
86 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
87 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
88 CORBA::ORB_var orb = init(0 , 0 ) ;
90 //SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
96 bool isSupervContainer = false;
97 if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
99 if (!isSupervContainer)
102 char* _argv[] = {""};
103 KERNEL_PYTHON::init_python(argc,argv);
107 wchar_t **changed_argv = new wchar_t*[argc];
108 for (int i = 0; i < argc; i++) {
109 changed_argv[i] = Py_DecodeLocale(argv[i], NULL);
112 PySys_SetArgv( argc , changed_argv ) ;
115 char *containerName = "";
118 containerName = argv[1] ;
123 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
124 ASSERT(!CORBA::is_nil(obj));
125 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
127 PortableServer::POAManager_var pman = root_poa->the_POAManager();
129 // add new container to the kill list
132 sprintf(aCommand, "addToKillList.py %d SALOME_Container", getpid());
136 Engines_Container_i * myContainer
137 = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
145 MESSAGE("SALOME_Registry_Server.cxx - orb->run()");
146 timer.ShowAbsolute();
149 HandleServerSideSignals(orb);
152 catch(CORBA::SystemException&)
154 INFOS("Caught CORBA::SystemException.");
156 catch(PortableServer::POA::ServantAlreadyActive&)
158 INFOS("Caught CORBA::ServantAlreadyActiveException");
160 catch(CORBA::Exception&)
162 INFOS("Caught CORBA::Exception.");
164 catch(std::exception& exc)
166 INFOS("Caught std::exception - "<<exc.what());
170 INFOS("Caught unknown exception.");
178 // delete myThreadTrace;