]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
#16706 fix1. Add check unkill process and new add to KillList
authorvuzlov <vuzlov@opencascade.com>
Thu, 17 Sep 2020 16:47:37 +0000 (19:47 +0300)
committervuzlov <vuzlov@opencascade.com>
Thu, 17 Sep 2020 16:47:37 +0000 (19:47 +0300)
bin/killSalomeWithPort.py
bin/runSalome.py

index 66fd32671d5bc2da8223bdbe7f8c1ccbfb1d00b3..b40bfbe6e5f648c13f734094e5fa3cfe581903eb 100755 (executable)
@@ -243,6 +243,11 @@ def __killMyPort(port, filedict):
                         killpid(int(pid))
                     except:
                         if verbose(): print("  ------------------ process %s : %s not found"% (pid, cmd[0]))
+                        if int(pid) in checkUnkillProcess():
+                            try:
+                                killpid(int(pid))
+                            except:
+                                pass
                         pass
                     pass # for pid ...
                 pass # for process_id ...
@@ -394,6 +399,34 @@ def killMyPortSpy(pid, port):
     killMyPort(port)
     return
 
+def checkUnkillProcess():
+    #check process in system after kill
+    from salome_utils import getUserName
+    user = getUserName()
+    if sys.platform != 'win32':
+        import subprocess
+        cmd = "ps -fea | grep 'vsr' | grep -e 'SALOME_' -e 'omniNames' | awk '{print $2}'" % user
+        prc = subprocess.getoutput(cmd)
+        if prc:
+            print("Salome process aren't killed\nCheck this PID: ", prc)
+            pass
+        return prc
+    else:
+        import subprocess
+        cmd = 'tasklist /fo csv | findstr /i "SALOME_ omniNames"'
+        prc = subprocess.getoutput(cmd)
+        # get only PID
+        try:
+            prc = prc.split()
+            prc = [prc[i].split(',') for i in range(0, len(prc)) if i % 2 == 0]
+            prc = [int(prc[j][1].replace('"', '')) for j in range(0, len(prc))]
+        except:
+            pass
+        if prc:
+            print("Salome process aren't killed\nCheck this PID: ", prc)
+            pass
+        return prc
+
 if __name__ == "__main__":
     if len(sys.argv) < 2:
         print("Usage: ")
@@ -410,6 +443,9 @@ if __name__ == "__main__":
             pass
         sys.exit(0)
         pass
+    elif sys.argv[1] == "--find":
+        checkUnkillProcess()
+        sys.exit(0)
     try:
         from salomeContextUtils import setOmniOrbUserPath #@UnresolvedImport
         setOmniOrbUserPath()
index b4fc7270f7634d38549f529798fe2d33d33209f3..fd9db84a9210a60488bc7fe0bfba82875e6556f7 100755 (executable)
@@ -474,6 +474,7 @@ def startSalome(args, modules_list, modules_root_dir):
     #
 
     clt=orbmodule.client(args)
+    addToPidict(args)
 
     #
     # Wake up session option
@@ -513,6 +514,7 @@ def startSalome(args, modules_list, modules_root_dir):
         myServer=LoggerServer(args)
         myServer.run()
         clt.waitLogger("Logger")
+        addToPidict(args)
 
     # Launch  Session Server (to show splash ASAP)
     #
@@ -521,6 +523,7 @@ def startSalome(args, modules_list, modules_root_dir):
         mySessionServ = SessionServer(args,args['modules'],modules_root_dir)
         mySessionServ.setpath(modules_list,modules_root_dir)
         mySessionServ.run()
+        addToPidict(args)
 
     #
     # Launch Registry Server,
@@ -534,6 +537,7 @@ def startSalome(args, modules_list, modules_root_dir):
           clt.waitNS("/Registry")
         else:
           clt.waitNSPID("/Registry",myServer.PID)
+        addToPidict(args)
 
     #
     # Launch Catalog Server,
@@ -549,6 +553,7 @@ def startSalome(args, modules_list, modules_root_dir):
           clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
         else:
           clt.waitNSPID("/Kernel/ModulCatalog",cataServer.PID,SALOME_ModuleCatalog.ModuleCatalog)
+        addToPidict(args)
 
     #
     # Launch SalomeDS Server,
@@ -564,6 +569,7 @@ def startSalome(args, modules_list, modules_root_dir):
           clt.waitNS("/Study")
         else:
           clt.waitNSPID("/Study",myServer.PID)
+        addToPidict(args)
 
     #
     # Launch LauncherServer
@@ -573,6 +579,7 @@ def startSalome(args, modules_list, modules_root_dir):
       myCmServer = LauncherServer(args)
       myCmServer.setpath(modules_list,modules_root_dir)
       myCmServer.run()
+      addToPidict(args)
 
     #
     # Launch ConnectionManagerServer
@@ -604,6 +611,7 @@ def startSalome(args, modules_list, modules_root_dir):
           clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
         else:
           clt.waitNSPID("/Containers/" + theComputer + "/FactoryServer",myServer.PID)
+        addToPidict(args)
 
     if 'pyContainer' in args['standalone']:
         raise Exception('Python containers no longer supported')
@@ -799,6 +807,14 @@ def no_main():
 
 # -----------------------------------------------------------------------------
 
+def addToPidict(args):
+    global process_id
+    from addToKillList import addToKillList
+    for pid, cmd in list(process_id.items()):
+        addToKillList(pid, cmd, args['port'])
+
+# -----------------------------------------------------------------------------
+
 def main(exeName=None):
     """Salome launch as a main application"""