-#ifdef HAVE_MPI2
- MPI_Init(&argc,&argv);
-#endif
-
- if(getenv ("DEBUGGER"))
- {
- setsig(SIGSEGV,&Handler);
- set_terminate(&terminateHandler);
- set_unexpected(&unexpectedHandler);
- }
-
- // Initialise the ORB.
- //SRN: BugID: IPAL9541, it's necessary to set a size of one message to be at least 100Mb
- //CORBA::ORB_var orb = CORBA::ORB_init( argc , argv ) ;
- ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
- ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
- CORBA::ORB_ptr orb = init(argc , argv ) ;
-
- // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
- INFOS_COMPILATION;
- BEGIN_OF(argv[0]);
-
- ASSERT(argc > 1);
- SCRUTE(argv[1]);
- bool isSupervContainer = false;
- if (strcmp(argv[1],"SuperVisionContainer") == 0) isSupervContainer = true;
-
- if (!isSupervContainer)
- {
- int _argc = 1;
- char* _argv[] = {""};
- KERNEL_PYTHON::init_python(argc,argv);
- }
- else
- {
- Py_Initialize() ;
- PySys_SetArgv( argc , argv ) ;
- }
-
- char *containerName = "";
- if(argc > 1)
- {
- containerName = argv[1] ;
- }
-
- try
- {
- CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
- ASSERT(!CORBA::is_nil(obj));
- PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-
- PortableServer::POAManager_var pman = root_poa->the_POAManager();
-
- // add new container to the kill list
-#ifndef WNT
- stringstream aCommand ;
- aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << ends ;
- system(aCommand.str().c_str());
-#endif
-
- Engines_Container_i * myContainer
- = new Engines_Container_i(orb, root_poa, containerName , argc , argv );
-
- pman->activate();
-
-#ifdef CHECKTIME
- Utils_Timer timer;
- timer.Start();
- timer.Stop();
- timer.ShowAbsolute();
-#endif
-
- HandleServerSideSignals(orb);
-
- if (!isSupervContainer)
- {
- PyGILState_STATE gstate = PyGILState_Ensure();
- //Delete python container that destroy orb from python (pyCont._orb.destroy())
- Py_Finalize();
- }
- else
- {
- orb->destroy();
- }
- }
- catch(CORBA::SystemException&)
- {
- INFOS("Caught CORBA::SystemException.");
- }
- catch(PortableServer::POA::ServantAlreadyActive&)
- {
- INFOS("Caught CORBA::ServantAlreadyActiveException");
- }
- catch(CORBA::Exception&)
- {
- INFOS("Caught CORBA::Exception.");
- }
- catch(std::exception& exc)
- {
- INFOS("Caught std::exception - "<<exc.what());
- }
- catch(...)
- {
- INFOS("Caught unknown exception.");
- }
-
-#ifdef HAVE_MPI2
- MPI_Finalize();
-#endif
-
- //END_OF(argv[0]);
- //LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
- //bp1->deleteInstance(bp1);
- return 0 ;