Salome HOME
Porting SALOME KERNEL to CMake
[modules/kernel.git] / src / Launcher / Launcher_Job_SALOME.cxx
index 91d94f1e3a0546c3f39d5606d42e19ebc0a517e3..b0c70f5b575aa7193047a980d0130976cfe44390 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -66,7 +66,12 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
 
   std::string launch_script = "/tmp/runSalome_" + _job_file_name + "_" + _launch_date + ".sh";
   std::ofstream launch_script_stream;
-  launch_script_stream.open(launch_script.c_str(), std::ofstream::out);
+  launch_script_stream.open(launch_script.c_str(), 
+                            std::ofstream::out
+#ifdef WIN32           
+ | std::ofstream::binary   //rnv: to avoid CL+RF end of line on windows
+#endif
+                           );
    
   // Begin of script
   launch_script_stream << "#!/bin/sh -f" << std::endl;
@@ -81,12 +86,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
   launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl;
 
   // -- Generates Catalog Resources
-  std::string resource_protocol = "ssh";
-  if (_resource_definition.ClusterInternalProtocol == rsh)
-    resource_protocol = "rsh";
-  else if (_resource_definition.ClusterInternalProtocol == srun)
-    resource_protocol = "srun";
-
+  std::string resource_protocol = ParserResourcesType::protocolToString(_resource_definition.ClusterInternalProtocol);
   launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl;
   launch_script_stream << "CATALOG_FILE=" << "CatalogResources_" << _launch_date << ".xml" << std::endl;
   launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl;
@@ -111,13 +111,14 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
   launch_script_stream << "NS_PORT_FILE_NAME=`basename $NS_PORT_FILE_PATH` &&\n";
 
   // Launch SALOME with an appli
-  launch_script_stream << _resource_definition.AppliPath << "/runAppli --terminal --ns-port-log=$NS_PORT_FILE_NAME > logs/salome_" << _launch_date << ".log 2>&1 &&" << std::endl;
+  launch_script_stream << _resource_definition.AppliPath << "/runAppli --terminal --ns-port-log=$NS_PORT_FILE_NAME --server-launch-mode=fork ";
+  launch_script_stream << "> logs/salome_" << _launch_date << ".log 2>&1 &&" << std::endl;
   launch_script_stream << "current=0 &&\n"
                        << "stop=20 &&\n"
-                       << "while ! test -f $NS_PORT_FILE_PATH\n"
+                       << "while ! test -s $NS_PORT_FILE_PATH\n"
                        << "do\n"
                        << "  sleep 2\n"
-                       << "  let current=current+1\n"
+                       << "  current=$((current+1))\n"
                        << "  if [ \"$current\" -eq \"$stop\" ] ; then\n"
                        << "    echo Error Naming Service failed ! >&2\n"
                        << "    exit\n"