From: prascle Date: Thu, 8 Apr 2004 13:34:29 +0000 (+0000) Subject: PR: modif run and kill salome, for colocalisation X-Git-Tag: Base_Ecole_Ete X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9baa34f0956c755cd9378118891b6d1bb31d1ab3;p=modules%2Fkernel.git PR: modif run and kill salome, for colocalisation --- diff --git a/bin/killSalome.py b/bin/killSalome.py index 63171b0b9..828c354ae 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -1,13 +1,17 @@ #!/usr/bin/env python -import os, string +import os, string, sys -from killSalomeWithPort import killSalome +from killSalomeWithPort import killMyPort -user = os.getenv('USER') -for file in os.listdir("/tmp"): - l = string.split(file, "_") - if len(l) >= 4: - if file[:len(user)] == user: - if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict": - killSalome(l[len(l)-3]) - pass +def killAllPorts(): + user = os.getenv('USER') + for file in os.listdir("/tmp"): + l = string.split(file, "_") + if len(l) >= 4: + if file[:len(user)] == user: + if l[len(l)-2] == "SALOME" and l[len(l)-1] == "pidict": + killMyPort(l[len(l)-3]) + pass + +if sys.argv[0] == "killSalome.py": + killAllPorts() diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 273e80d1b..3b364f955 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -2,7 +2,7 @@ import os, sys, pickle, signal, commands ########## kills all salome processes with the given port ########## -def killSalome(port): +def killMyPort(port): filedict='/tmp/'+os.getenv('USER')+"_"+port+'_SALOME_pidict' found = 0 try: @@ -20,6 +20,7 @@ def killSalome(port): for process_id in process_ids: for pid, cmd in process_id.items(): + print "stop process %s : %s"% (pid, cmd[0]) try: os.kill(int(pid),signal.SIGKILL) except: @@ -37,4 +38,4 @@ def killSalome(port): if sys.argv[0] == "killSalomeWithPort.py": for port in sys.argv[1:]: - killSalome(port) + killMyPort(port) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 257817437..27dbfcf33 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -1,7 +1,10 @@ import os, glob, string, sys import xml.sax +# ----------------------------------------------------------------------------- + ### xml reader for launch configuration file usage + class xml_parser: def __init__(self, fileName): self.space = [] @@ -45,6 +48,12 @@ class xml_parser: self.opts[key]=[] pass self.opts[key].append(attrs.getValue("name")) + elif self.space == ["Configuration-list","embedded-list"]: + self.opts["embedded"] = [] + pass + elif self.space == ["Configuration-list","standalone-list"]: + self.opts["standalone"] = [] + pass elif self.space == ["Configuration-list","containers-list"]: self.opts["containers"] = [] pass @@ -59,6 +68,10 @@ class xml_parser: #print "Characters content:",content if self.current: self.opts[self.current] = self.CorrectBoolean(content) + elif self.space == ["Configuration-list","embedded-list", "embeddedserver"]: + self.opts["embedded"].append(content) + elif self.space == ["Configuration-list","standalone-list", "standaloneserver"]: + self.opts["standalone"].append(content) elif self.space == ["Configuration-list","containers-list", "containertype"]: self.opts["containers"].append(content) pass @@ -77,7 +90,10 @@ class xml_parser: self.read = None pass +# ----------------------------------------------------------------------------- + ### searching for launch configuration file : $HOME/.$(application_name)/$(application_name).launch + appname = None filename = None for bindir in glob.glob(os.environ["KERNEL_ROOT_DIR"]+"/bin/*"): @@ -104,6 +120,7 @@ elif not filename or not os.path.exists(filename): pass ### get options from launch configuration file + try: p = xml_parser(filename) except: @@ -120,6 +137,7 @@ else: args["appname"] = appname ### searching for my port + my_port = 2809 try: file = open(os.environ["OMNIORB_CONFIG"], "r") @@ -136,7 +154,10 @@ except: args["port"] = my_port +# ----------------------------------------------------------------------------- + ### command line options reader + def options_parser(line): source = line list = [] @@ -148,6 +169,8 @@ def options_parser(line): list = [] pass + print "source=",source + result = {} i = 0 while i < len(source): @@ -170,19 +193,28 @@ def options_parser(line): pass return result -### read command-line options +# ----------------------------------------------------------------------------- + +### read command-line options : each arg given in command line supersedes arg from xml config file + try: opts = options_parser(sys.argv[1:]) + print "opts=",opts kernel_root_dir=os.environ["KERNEL_ROOT_DIR"] except: opts["h"] = 1 pass ### check all options are right + +opterror=0 for opt in opts: - if not opt in ("h","g","l","x","m","c","p","k","t"): - opts["h"] = 1 + if not opt in ("h","g","l","x","m","e","s","c","p","k","t"): + print "command line error: -", opt + opterror=1 +if opterror == 1: + opts["h"] = 1 if opts.has_key("h"): print """USAGE: runSalome.py [options] @@ -194,8 +226,15 @@ if opts.has_key("h"): --xterm or -x : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre --modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue or -m=module1,module2,... - --containers=cpp,python,superv: lancement des containers cpp, python et de supervision - or -c=cpp,python,superv + --embedded=registry,study,moduleCatalog,cppContainer + or -e=registry,study,moduleCatalog,cppContainer + : serveurs CORBA embarqués (par defaut: registry,study,moduleCatalog,cppContainer) + : (logger,pyContainer,supervContainer ne peuvent pas être embarqués + --standalone=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer + or -s=registry,study,moduleCatalog,cppContainer,pyContainer,supervContainer + : executables serveurs CORBA indépendants (par défaut: pyContainer,supervContainer) + --containers=cpp,python,superv: (obsolete) lancement des containers cpp, python et de supervision + or -c=cpp,python,superv : = on prend les defauts de -e et -s --portkill or -p : kill the salome with current port --killall or -k : kill salome @@ -216,6 +255,10 @@ for opt in opts: args['xterm'] = 1 elif opt == 'm': args['modules'] = opts['m'] + elif opt == 'e': + args['embedded'] = opts['e'] + elif opt == 's': + args['standalone'] = opts['s'] elif opt == 'c': args['containers'] = opts['c'] elif opt == 'p': @@ -229,3 +272,5 @@ for opt in opts: if 't' in opts: args['gui'] = 0 pass + +print "args=",args diff --git a/bin/runSalome b/bin/runSalome index 48951369e..37f6614e2 100755 --- a/bin/runSalome +++ b/bin/runSalome @@ -16,17 +16,32 @@ EOF done if [ $# -ne 0 ] ; then - python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* + python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py $* else python ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py fi -#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM --xterm --containers=cpp,python --killall -#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --xterm --containers=cpp,python --killall -#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --gui --modules=GEOM,SMESH,VISU,SUPERV,MED --logger --xterm -#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --modules=GEOM,SMESH,VISU,SUPERV,MED -#python -i ${KERNEL_ROOT_DIR}/bin/salome/runSalome.py --help - +# ----------------------------------------------------------------------------- +# examples: +# --------- +# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome +# +# parameters read from $HOME/.salome/salome.launch +# if the config file does not exist, it is created with default values +# +# +# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome --modules=GEOM,SMESH,VISU,SUPERV,MED --embedded=registry,study,moduleCatalog,cppContainer --standalone=pyContainer,supervContainer --xterm --killall +# +# parameter from command line supersedes thoses from $HOME/.salome/salome.launch +# +# Some CORBA servers could be launched in the SALOME_Session_Server +# (embedded = same process) or in a separate process (standalone): +# --> registry,study,moduleCatalog,cppContainer +# Other CORBA servers could only be launched in separate process (standalone): +# --> pyContainer,supervContainer +# +# $: ${KERNEL_ROOT_DIR}/bin/salome/runSalome -h +# help # ----------------------------------------------------------------------------- # # l'option -i permet de garder l'interpreteur python ouvert : diff --git a/bin/runSalome.py b/bin/runSalome.py index 8ba32f511..588913a1c 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -7,16 +7,23 @@ import launchConfigureParser args = launchConfigureParser.args ### kill servers if it is need -if args['killall']: - import killSalome -elif args['portkill']: - from killSalomeWithPort import killSalome - filedict='/tmp/'+os.getenv('USER')+"_"+str(args['port'])+'_'+args['appname'].upper()+'_pidict' + +from killSalome import killAllPorts + +def killLocalPort(): + from killSalomeWithPort import killMyPort + my_port=str(args['port']) try: - killSalome(my_port) + killMyPort(my_port) except: + print "problem in killLocalPort()" pass pass + +if args['killall']: + killAllPorts() +elif args['portkill']: + killLocalPort() # ----------------------------------------------------------------------------- # @@ -164,13 +171,18 @@ class SessionLoader(Server): CMD=CMD+['GUI'] class SessionServer(Server): - #CMD=['SALOME_Session_Server'] - SCMD1=['SALOME_Session_Server', - '--with','Registry','(','--salome_session','theSession',')', - '--with','ModuleCatalog','(','-common'] - SCMD2=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml',')', - '--with','SALOMEDS','(',')', - '--with','Container','(','FactoryServer',')'] + SCMD1=['SALOME_Session_Server'] + SCMD2=[] + if 'registry' in args['embedded']: + SCMD1+=['--with','Registry','(','--salome_session','theSession',')'] + if 'moduleCatalog' in args['embedded']: + SCMD1+=['--with','ModuleCatalog','(','-common'] + SCMD2+=['-personal','${HOME}/Salome/resources/CatalogModulePersonnel.xml',')'] + if 'study' in args['embedded']: + SCMD2+=['--with','SALOMEDS','(',')'] + if 'cppContainer' in args['embedded']: + SCMD2+=['--with','Container','(','FactoryServer',')'] + def setpath(self,modules_list): cata_path=[] list_modules = modules_list[:] @@ -180,7 +192,10 @@ class SessionServer(Server): module_cata=module+"Catalog.xml" print " ", module_cata cata_path.extend(glob.glob(os.path.join(module_root_dir,"share",args['appname'],"resources",module_cata))) - self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 + if 'moduleCatalog' in args['embedded']: + self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 + else: + self.CMD=self.SCMD1 + self.SCMD2 class NotifyServer(Server): myLogName = os.environ["LOGNAME"] @@ -275,50 +290,37 @@ def startSalome(): NotifyServer().run() # - # Lancement Registry Server - # - - #RegistryServer().run() - - # - # Attente de la disponibilité du Registry dans le Naming Service - # - - #clt.waitNS("/Registry") - - # - # Lancement Catalog Server + # Lancement Registry Server, attente de la disponibilité du Registry dans le Naming Service # - - #cataServer=CatalogServer() - #cataServer.setpath(modules_list) - #cataServer.run() + if 'registry' not in args['embedded']: + RegistryServer().run() + clt.waitNS("/Registry") # - # Attente de la disponibilité du Catalog Server dans le Naming Service + # Lancement Catalog Server, attente de la disponibilité du Catalog Server dans le Naming Service # - #import SALOME_ModuleCatalog - #clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) + if 'moduleCatalog' not in args['embedded']: + cataServer=CatalogServer() + cataServer.setpath(modules_list) + cataServer.run() + import SALOME_ModuleCatalog + clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog) # - # Lancement SalomeDS Server + # Lancement SalomeDS Server, attente de la disponibilité du SalomeDS dans le Naming Service # os.environ["CSF_PluginDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") os.environ["CSF_SALOMEDS_ResourcesDefaults"]=os.path.join(modules_root_dir["KERNEL"],"share",args['appname'],"resources") - #SalomeDSServer().run() if "GEOM" in modules_list: print "GEOM OCAF Resources" os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share",args['appname'],"resources") - - # - # Attente de la disponibilité du SalomeDS dans le Naming Service - # - - #clt.waitNS("/myStudyManager") + if 'study' not in args['embedded']: + SalomeDSServer().run() + clt.waitNS("/myStudyManager") # # Lancement Session Server @@ -327,7 +329,6 @@ def startSalome(): mySessionServ=SessionServer() mySessionServ.setpath(modules_list) mySessionServ.run() - #SessionServer().run() # # Attente de la disponibilité du Session Server dans le Naming Service @@ -347,50 +348,28 @@ def startSalome(): theComputer = computerSplitName[0] # - # Lancement Container C++ local + # Lancement Container C++ local, attente de la disponibilité du Container C++ local dans le Naming Service # - #if 'cpp' in args['containers']: - #ContainerCPPServer().run() - # - # Attente de la disponibilité du Container C++ local dans le Naming Service - # - - #clt.waitNS("/Containers/" + theComputer + "/FactoryServer") + if 'cppContainer' in args['standalone']: + ContainerCPPServer().run() + clt.waitNS("/Containers/" + theComputer + "/FactoryServer") # - # Lancement Container Python local + # Lancement Container Python local, attente de la disponibilité du Container Python local dans le Naming Service # - if 'python' in args['containers']: + if 'pyContainer' in args['standalone']: ContainerPYServer().run() - - # - # Attente de la disponibilité du Container Python local dans le Naming Service - # - clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy") - if 'superv' in args['containers']: - - # - # Lancement Container Supervision local - # - - ContainerSUPERVServer().run() - - # - # Attente de la disponibilité du Container Supervision local dans le Naming Service - # - - clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer") - - # - # Activation du GUI de Session Server + # Lancement Container Supervision local, attente de la disponibilité du Container Supervision local dans le Naming Service # - - #session.GetInterface() + + if 'supervContainer' in args['standalone']: + ContainerSUPERVServer().run() + clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer") end_time = os.times() print @@ -431,15 +410,16 @@ if __name__ == "__main__": pickle.dump(process_ids,fpid) fpid.close() - print - print "Saving of the dictionary of Salome processes in ", filedict - print "To kill SALOME processes launch : python killSalome.py from" - print "a console or killSalome() from the present interpreter, if it is not closed." - print - print "runSalome, with --killall option, starts with killing the processes resulting from the previous execution." - print - print "To launch only GUI only execute startGUI() from the present interpreter," - print "if it is not closed." + print """ + Saving of the dictionary of Salome processes in %s + To kill SALOME processes from a console (kill all sessions from all ports): + python killSalome.py + To kill SALOME from the present interpreter, if it is not closed : + killLocalPort() --> kill this session + killAllPorts() --> kill all sessions + + runSalome, with --killall option, starts with killing the processes resulting from the previous execution. + """%filedict # # Impression arborescence Naming Service diff --git a/bin/salome.launch b/bin/salome.launch index d4b57a6ed..920c968f6 100644 --- a/bin/salome.launch +++ b/bin/salome.launch @@ -17,9 +17,14 @@ - - cpp - python - superv - + + registry + study + moduleCatalog + cppContainer + + + pyContainer + supervContainer +