Salome HOME
Merge branch 'omu/launcher_evol'
[modules/kernel.git] / src / Launcher / Launcher_Job_SALOME.cxx
index c3b79b3f5d611f482072474a2a7f01814e618b4c..ee2812c1b6f5cae12d61d3d316d198bb928ee3a9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2015  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2017  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
 #define _chmod chmod
 #endif
 
+#include <sstream>
+
 Launcher::Job_SALOME::Job_SALOME() {}
 
 Launcher::Job_SALOME::~Job_SALOME() {}
 
-void 
+void
 Launcher::Job_SALOME::setResourceDefinition(const ParserResourcesType & resource_definition)
 {
   // Check resource_definition
@@ -58,21 +60,22 @@ Launcher::Job_SALOME::update_job()
 }
 
 #ifdef WITH_LIBBATCH
-std::string 
+std::string
 Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
 {
   // parameters
   std::string work_directory = params[Batch::WORKDIR].str();
-
-  std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + ".sh";
+  std::ostringstream str_pid;
+  str_pid << ::getpid();
+  std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh";
   std::ofstream launch_script_stream;
-  launch_script_stream.open(launch_script.c_str(), 
+  launch_script_stream.open(launch_script.c_str(),
                             std::ofstream::out
-#ifdef WIN32           
+#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;
   launch_script_stream << "cd " << work_directory << std::endl;
@@ -115,10 +118,9 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
 
   // Create file for ns-port-log
   launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << _resource_definition.AppliPath << "/USERS/nsport_XXXXXX) &&\n";
-  launch_script_stream << "NS_PORT_FILE_NAME=$(basename \"$NS_PORT_FILE_PATH\") &&\n";
 
   // Launch SALOME with an appli
-  launch_script_stream << _resource_definition.AppliPath << "/salome start --terminal --ns-port-log=\"$NS_PORT_FILE_NAME\" --server-launch-mode=fork ";
+  launch_script_stream << _resource_definition.AppliPath << "/salome start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --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"
@@ -138,8 +140,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
   addJobTypeSpecificScript(launch_script_stream);
 
   // End
-  launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" shutdownSalome.py" << std::endl;
-  //launch_script_stream << "sleep 10" << std::endl;
+  launch_script_stream << _resource_definition.AppliPath << "/salome kill \"$appli_port\"" << std::endl;
 
   // Return
   launch_script_stream.flush();
@@ -148,4 +149,3 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params)
   return launch_script;
 }
 #endif
-