-// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2006-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
#include "LoadState.hxx"
#include "Dispatcher.hxx"
#include "LinkInfo.hxx"
+#include "ObserverAsPlugin.hxx"
-#ifdef SALOME_KERNEL
+#include "KernelBasis.hxx"
+#include "SALOME_Launcher.hxx"
+#include "ServiceUnreachable.hxx"
+#include "SALOME_NamingService_Wrapper.hxx"
#include "SALOME_NamingService.hxx"
#include "SALOME_ModuleCatalog.hh"
+#include "SALOMESDS_DataServerManager.hxx"
#include "Basics_Utils.hxx"
-#endif
#include <iostream>
#include <fstream>
string lockFile;
} thread_st;
-#ifndef WIN32
-#include <dlfcn.h>
-#include <stdlib.h>
-#endif
-
-std::string LoadedDriverPluginLibrary;
-void *HandleOnLoadedPlugin=0;
-void (*DefineCustomObservers)(YACS::ENGINE::Dispatcher *, YACS::ENGINE::ComposedNode *, YACS::ENGINE::Executor *)=0;
-void (*CleanUpObservers) ()=0;
-
-void LoadObserversPluginIfAny(YACS::ENGINE::ComposedNode *rootNode, YACS::ENGINE::Executor *executor)
-{
- static const char SYMBOLE_NAME_1[]="DefineCustomObservers";
- static const char SYMBOLE_NAME_2[]="CleanUpObservers";
-#ifndef WIN32
- Dispatcher *disp(Dispatcher::getDispatcher());
- if(!disp)
- throw YACS::Exception("Internal error ! No dispatcher !");
- char *yacsDriverPluginPath(getenv("YACS_DRIVER_PLUGIN_PATH"));
- if(!yacsDriverPluginPath)
- return ;
- void *handle(dlopen(yacsDriverPluginPath, RTLD_LAZY | RTLD_GLOBAL));
- if(!handle)
- {
- std::string message(dlerror());
- std::ostringstream oss; oss << "Error during load of \"" << yacsDriverPluginPath << "\" defined by the YACS_DRIVER_PLUGIN_PATH env var : " << message;
- throw YACS::Exception(oss.str());
- }
- DefineCustomObservers=(void (*)(YACS::ENGINE::Dispatcher *, YACS::ENGINE::ComposedNode *, YACS::ENGINE::Executor *))(dlsym(handle,SYMBOLE_NAME_1));
- if(!DefineCustomObservers)
- {
- std::ostringstream oss; oss << "Error during load of \"" << yacsDriverPluginPath << "\" ! Library has been correctly loaded but symbol " << SYMBOLE_NAME_1 << " does not exists !";
- throw YACS::Exception(oss.str());
- }
- CleanUpObservers=(void (*)())(dlsym(handle,SYMBOLE_NAME_2));
- if(!CleanUpObservers)
- {
- std::ostringstream oss; oss << "Error during load of \"" << yacsDriverPluginPath << "\" ! Library has been correctly loaded but symbol " << SYMBOLE_NAME_2 << " does not exists !";
- throw YACS::Exception(oss.str());
- }
- HandleOnLoadedPlugin=handle;
- DefineCustomObservers(disp,rootNode,executor);
-#endif
-}
-
-void UnLoadObserversPluginIfAny()
-{
-#ifndef WIN32
- if(HandleOnLoadedPlugin)
- {
- CleanUpObservers();
- dlclose(HandleOnLoadedPlugin);
- }
-#endif
-}
-
#if defined WIN32 || defined __APPLE__
static int
#else
return true;
}
+void InitializeSSL()
+{
+ setSSLMode(true);
+ KERNEL::getLauncherSA();
+}
+
+void shutdownServers()
+{
+ // shutdown data server scopes
+ try
+ {
+ YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+ runTime->loadModulCatalog();
+ CORBA::ORB_ptr orb = runTime->getOrb();
+ if (orb)
+ {
+ SALOME_NamingService_Wrapper namingService(orb);
+ CORBA::Object_var objDSM(namingService.Resolve(SALOMESDS::DataServerManager::NAME_IN_NS));
+ SALOME::DataServerManager_var dsm(SALOME::DataServerManager::_narrow(objDSM));
+ if ( !CORBA::is_nil(dsm) )
+ dsm->shutdownScopes();
+ }
+ }
+ catch(const CORBA::Exception& )
+ {
+ // ignore and continue
+ }
+ catch(ServiceUnreachable& e)
+ {
+ // ignore and continue
+ }
+}
+
int main (int argc, char* argv[])
{
myArgs.dump = 0;
myArgs.loadState = (char *)"";
myArgs.xmlSchema = (char *)"";
- myArgs.shutdown = 1;
+ myArgs.shutdown = 10;
myArgs.reset = 0;
myArgs.killPort = 0;
myArgs.init_ports.clear();
setsig(SIGTERM,&Handler);
#endif
+ InitializeSSL();
+
timer("Starting ");
long flags = RuntimeSALOME::UsePython + RuntimeSALOME::UseCorba + RuntimeSALOME::UseXml + \
RuntimeSALOME::UseCpp + RuntimeSALOME::UseSalome;
try
{
YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+ runTime->loadModulCatalog();
CORBA::ORB_ptr orb = runTime->getOrb();
if (orb)
{
- SALOME_NamingService namingService(orb);
+ SALOME_NamingService_Wrapper namingService(orb);
CORBA::Object_var obj = namingService.Resolve("/Kernel/ModulCatalog");
SALOME_ModuleCatalog::ModuleCatalog_var aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
if (! CORBA::is_nil(aModuleCatalog))
}
if (myArgs.stop)
+ {
if (strlen(myArgs.dumpErrorFile) >0)
executor.setStopOnError(true, myArgs.dumpErrorFile);
else
executor.setStopOnError(false, myArgs.dumpErrorFile);
-
+ }
if(myArgs.display>0)
{
std::ofstream f("toto");
st->lockFile = rootFile + ".lock";
pthread_create(&th,NULL,&dumpState,(void*)st);
}
- LoadObserversPluginIfAny(p,&executor);
+ YACS::ENGINE::LoadObserversPluginIfAny(p,&executor);
cerr << "+++++++++++++++++++ start calculation +++++++++++++++++++" << endl;
executor.RunW(p,myArgs.display, fromScratch);
cerr << "+++++++++++++++++++ end calculation +++++++++++++++++++" << endl;
if(myArgs.shutdown < 999)
{
p->shutdown(myArgs.shutdown);
+ shutdownServers();
}
delete p;
Runtime* r=YACS::ENGINE::getRuntime();
r->fini();
delete r;
delete disp;
- UnLoadObserversPluginIfAny();
+ YACS::ENGINE::UnLoadObserversPluginIfAny();
return return_value;
}
catch (YACS::Exception& e)