From: rnv Date: Tue, 28 May 2019 08:46:05 +0000 (+0300) Subject: 16988 [CEA] Use of SALOME_Launcher with sat launcher files X-Git-Tag: EMC2P_V1_1_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b3f6bd51caa213b97097ac31c6350c613403720d;p=modules%2Fkernel.git 16988 [CEA] Use of SALOME_Launcher with sat launcher files --- diff --git a/src/Launcher/Launcher_Job_CommandSALOME.cxx b/src/Launcher/Launcher_Job_CommandSALOME.cxx index 59db9e09f..4e5502691 100644 --- a/src/Launcher/Launcher_Job_CommandSALOME.cxx +++ b/src/Launcher/Launcher_Job_CommandSALOME.cxx @@ -26,6 +26,7 @@ #endif #include +#include const char Launcher::Job_CommandSALOME::TYPE_NAME[] = "command_salome"; @@ -42,9 +43,17 @@ Launcher::Job_CommandSALOME::~Job_CommandSALOME() {} std::string Launcher::Job_CommandSALOME::runCommandString() { std::ostringstream result; - result << _resource_definition.AppliPath - << "/salome shell ./" - << _job_file_name_complete; + struct stat statbuf; + if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode)) + // case of a salome launcher file + result << _resource_definition.AppliPath + << " shell ./" + << _job_file_name_complete; + else + // case of a salome appli dir + result << _resource_definition.AppliPath + << "/salome shell ./" + << _job_file_name_complete; return result.str(); } #endif diff --git a/src/Launcher/Launcher_Job_PythonSALOME.cxx b/src/Launcher/Launcher_Job_PythonSALOME.cxx index 46c362fbf..42a80501a 100644 --- a/src/Launcher/Launcher_Job_PythonSALOME.cxx +++ b/src/Launcher/Launcher_Job_PythonSALOME.cxx @@ -20,6 +20,7 @@ // Author: André RIBES - EDF R&D // #include "Launcher_Job_PythonSALOME.hxx" +#include const char Launcher::Job_PythonSALOME::TYPE_NAME[] = "python_salome"; @@ -39,5 +40,10 @@ Launcher::Job_PythonSALOME::setJobFile(const std::string & job_file) void Launcher::Job_PythonSALOME::addJobTypeSpecificScript(std::ofstream & launch_script_stream) { - launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl; + struct stat statbuf; + if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode)) + // case where AppliPath hold a salome launcher file + launch_script_stream << _resource_definition.AppliPath << " shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl; + else + launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" python " << _job_file_name_complete << " > logs/python_" << _launch_date << ".log 2>&1" << std::endl; } diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 492875a74..2c377ce96 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -31,6 +31,7 @@ #define _chmod chmod #include #endif +#include #include @@ -72,7 +73,11 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) #else str_pid << ::getpid(); #endif - std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh"; + struct stat statbuf; + // true if APPLI holds a salome file launcher (in state of an application directory) + bool is_launcher_file=stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode); + std::string launch_tmp_dir = Kernel_Utils::GetTmpDir(); + std::string launch_script = launch_tmp_dir + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out @@ -125,10 +130,17 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "fi" << std::endl; // Create file for ns-port-log - launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << _resource_definition.AppliPath << "/USERS/nsport_XXXXXX) &&\n"; + if (is_launcher_file) + // for a salome application file, we write NS_PORT_FILE_PATH in launch_tmp_dir + launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << launch_tmp_dir << "nsport_XXXXXX) &&\n"; + else + launch_script_stream << "NS_PORT_FILE_PATH=$(mktemp " << _resource_definition.AppliPath << "/USERS/nsport_XXXXXX) &&\n"; // Launch SALOME with an appli - launch_script_stream << _resource_definition.AppliPath << "/salome start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --server-launch-mode=fork "; + if (is_launcher_file) + launch_script_stream << _resource_definition.AppliPath << " start --terminal --ns-port-log=\"$NS_PORT_FILE_PATH\" --server-launch-mode=fork "; + else + 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" @@ -150,7 +162,10 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) launch_script_stream << "echo $? > logs/exit_code.log" << std::endl; // End - launch_script_stream << _resource_definition.AppliPath << "/salome kill \"$appli_port\"" << std::endl; + if (is_launcher_file) + launch_script_stream << _resource_definition.AppliPath << " kill \"$appli_port\"" << std::endl; + else + launch_script_stream << _resource_definition.AppliPath << "/salome kill \"$appli_port\"" << std::endl; // Return launch_script_stream.flush(); diff --git a/src/Launcher/Launcher_Job_YACSFile.cxx b/src/Launcher/Launcher_Job_YACSFile.cxx index 286cc5e4a..05cfbf106 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -21,6 +21,7 @@ // #include "Launcher_Job_YACSFile.hxx" #include +#include const char Launcher::Job_YACSFile::TYPE_NAME[] = "yacs_file"; @@ -42,7 +43,12 @@ Launcher::Job_YACSFile::setJobFile(const std::string & job_file) void Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream) { - launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete; + struct stat statbuf; + if(stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode)) + // case of a salome launcher file + launch_script_stream << _resource_definition.AppliPath << " shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete; + else + launch_script_stream << _resource_definition.AppliPath << "/salome shell -p \"$appli_port\" -- driver -k\"$appli_port\" " << _job_file_name_complete; if (_dumpState > 0) launch_script_stream << " --dump=" << _dumpState; if(! _yacsDriverOptions.empty()) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 650160d61..6ff79f3fd 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -622,9 +622,18 @@ void ResourcesManager_cpp::AddDefaultResourceInCatalog() resource.Protocol = sh; resource.Batch = none; #ifndef WIN32 + struct stat statbuf; if (getenv("HOME") != NULL && getenv("APPLI") != NULL) { - resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI"); + if (stat(getenv("APPLI"), &statbuf) ==0 && S_ISREG(statbuf.st_mode)) + { + // if $APPLI is a regular file, we asume it's a salome Launcher file + resource.AppliPath = string(getenv("APPLI")); + } + else + { + resource.AppliPath = string(getenv("HOME")) + "/" + getenv("APPLI"); + } } string tmpdir = "/tmp"; if (getenv("TMPDIR") != NULL)