dest="wake_up_session", default=False,
help=help_str)
+ # Launch server processes with a specific command. Default: False.
+ help_str = "Launch server processes with a specific command."
+ o_slc = optparse.Option("--server-launch-cmd",
+ metavar="<server_launch_cmd>",
+ type="string",
+ action="store",
+ dest="server_launch_cmd",
+ help=help_str)
+
# All options
opt_list = [o_t,o_g, # GUI/Terminal
o_d,o_o, # Desktop
o_shutdown,
o_foreground,
o_wake_up,
+ o_slc, # Server launch command
]
#std_options = ["gui", "desktop", "log_file", "py_scripts", "resources",
filename = cmd_opts.play_script_file
args[play_nam] += re.split( "[:;,]", filename )
+ # Server launch command
+ if cmd_opts.server_launch_cmd is not None:
+ args["server_launch_cmd"] = cmd_opts.server_launch_cmd
+
# return arguments
os.environ[config_var] = separator.join(dirs)
#print "Args: ", args
import sys, os, string, glob, time, pickle, re
import orbmodule
import setenv
-from server import *
from launchConfigureParser import verbose
-from server import process_id
+from server import process_id, Server
if sys.platform == "win32":
SEP = ";"
if verbose(): print "startSalome ", args
+ #
+ # Set server launch command
+ #
+ if args.has_key('server_launch_cmd'):
+ Server.set_server_launch_cmd(args['server_launch_cmd'])
+
#
# Wake up session option
#
#
import os, sys, string
+from salome_utils import getHostName
process_id = {}
# -----------------------------------------------------------------------------
class Server:
"""Generic class for CORBA server launch"""
+
+ server_launch_args = []
def initArgs(self):
self.PID=None
self.args=args
self.initArgs()
+ @staticmethod
+ def set_server_launch_cmd(cmd):
+ if cmd == "srun":
+ Server.server_launch_args = ["srun", "-n", "1", "-N", "1"]
+ Server.server_launch_args += ["--share", "--nodelist=%s" % getHostName()]
+ else:
+ print >>sys.stderr, "Unknown server launch command:%s" % cmd
def run(self):
global process_id
#I am a daemon
os.close(0) #close stdin
os.open("/dev/null", os.O_RDWR) # redirect standard input (0) to /dev/null
+ all_args = Server.server_launch_args + args
try:
- os.execvp(args[0], args)
+ os.execvp(all_args[0], all_args)
except OSError, e:
if args[0] != "notifd":
print >>sys.stderr, "(%s) launch failed: %d (%s)" % (args[0],e.errno, e.strerror)
std::string command;
// if a parallel container is launched in batch job, command is: "mpirun -np nbproc -machinefile nodesfile SALOME_MPIContainer"
if( getenv("LIBBATCH_NODEFILE") != NULL && params.isMPI )
- command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
+ command = BuildCommandToLaunchLocalContainer(resource_selected, params, machFile, container_exe);
// if a container is launched on localhost, command is "SALOME_Container" or "mpirun -np nbproc SALOME_MPIContainer"
else if(hostname == Kernel_Utils::GetHostname())
- command = BuildCommandToLaunchLocalContainer(params, machFile, container_exe);
+ command = BuildCommandToLaunchLocalContainer(resource_selected, params, machFile, container_exe);
// if a container is launched in remote mode, command is "ssh resource_selected SALOME_Container" or "ssh resource_selected mpirun -np nbproc SALOME_MPIContainer"
else
command = BuildCommandToLaunchRemoteContainer(resource_selected, params, container_exe);
// "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \
// SALOME_Container containerName &"
- if (resInfo.Protocol == rsh)
- command = "rsh ";
- else if (resInfo.Protocol == ssh)
- command = "ssh ";
- else if (resInfo.Protocol == srun)
- command = "srun -n 1 -N 1 --share --nodelist=";
- else
- throw SALOME_Exception("Unknown protocol");
-
- // no need to redefine the user with srun, the job user is taken by default (note: for srun, user id can be specified with " --uid=<user>")
- if (resInfo.Protocol != srun && resInfo.UserName != "")
- {
- command += "-l ";
- command += resInfo.UserName;
- command += " ";
- }
-
- command += resInfo.HostName;
- command += " ";
+ command = getCommandToRunProcess(resInfo.Protocol, resInfo.HostName, resInfo.UserName);
if (resInfo.AppliPath != "")
command += resInfo.AppliPath; // path relative to user@machine $HOME
//=============================================================================
std::string
SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
-(const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
+(const std::string & resource_name, const Engines::ContainerParameters& params, const std::string& machinesFile, const std::string& container_exe)
{
_TmpFileName = BuildTemporaryFileName();
std::string command;
#endif
}
}
+
+ const ParserResourcesType& resInfo = _ResManager->GetImpl()->GetResourcesDescr(resource_name);
+ o << getCommandToRunProcess(resInfo.Protocol);
+
if (isPythonContainer(params.container_name))
o << "SALOME_ContainerPy.py ";
else
return thepids;
}
+std::string SALOME_ContainerManager::getCommandToRunProcess(AccessProtocolType protocol,
+ const std::string & hostname,
+ const std::string & username)
+{
+ std::string hostRealName = hostname;
+ std::string localHostRealName = Kernel_Utils::GetHostname();
+ bool isLocal = false;
+ if (hostname == "localhost" || hostname == localHostRealName)
+ {
+ isLocal = true;
+ hostRealName = localHostRealName;
+ }
+
+ std::ostringstream command;
+ switch (protocol)
+ {
+ case rsh:
+ if (!isLocal)
+ {
+ command << "rsh ";
+ if (username != "")
+ {
+ command << "-l " << username << " ";
+ }
+ command << hostRealName << " ";
+ }
+ break;
+ case ssh:
+ if (!isLocal)
+ {
+ command << "ssh ";
+ if (username != "")
+ {
+ command << "-l " << username << " ";
+ }
+ command << hostRealName << " ";
+ }
+ break;
+ case srun:
+ // no need to redefine the user with srun, the job user is taken by default
+ // (note: for srun, user id can be specified with " --uid=<user>")
+ command << "srun -n 1 -N 1 --share --nodelist=" << hostRealName << " ";
+ break;
+ default:
+ throw SALOME_Exception("Unknown protocol");
+ }
+
+ return command.str();
+}
+
bool
SALOME_ContainerManager::checkPaCOParameters(Engines::ContainerParameters & params, std::string resource_selected)
{
const Engines::ContainerParameters& params,
const std::string& container_exe="SALOME_Container");
- std::string BuildCommandToLaunchLocalContainer(const Engines::ContainerParameters& params,
+ std::string BuildCommandToLaunchLocalContainer(const std::string & resource_name,
+ const Engines::ContainerParameters& params,
const std::string& machinesFile,
const std::string& container_exe="SALOME_Container");
std::set<pid_t> getpidofprogram(const std::string program);
+ std::string getCommandToRunProcess(AccessProtocolType protocol,
+ const std::string & hostname = "localhost",
+ const std::string & username = "");
+
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
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 ";
+ if (_resource_definition.ClusterInternalProtocol != rsh &&
+ _resource_definition.ClusterInternalProtocol != ssh)
+ {
+ launch_script_stream << "--server-launch-cmd=" << resource_protocol << " ";
+ }
+ launch_script_stream << "> logs/salome_" << _launch_date << ".log 2>&1 &&" << std::endl;
launch_script_stream << "current=0 &&\n"
<< "stop=20 &&\n"
<< "while ! test -s $NS_PORT_FILE_PATH\n"