@@ -652,51 +652,6 @@ def find_docker_console():
652652
653653 LogManager .logger .info ("Run application transition finished" )
654654
655- def terminate_harmonic_processes (self ):
656- """
657- Terminate all processes within the Docker container whose command line contains 'gz' or 'launch'.
658- """
659- LogManager .logger .info ("Terminate Harmonic process" )
660- keywords = ["gz" , "launch" ]
661- for keyword in keywords :
662- try :
663- ps_aux_cmd = ["ps" , "aux" ]
664- grep_cmd = ["grep" , keyword ]
665- grep_exclude_cmd = ["grep" , "-v" , "grep" ]
666-
667- ps_aux_proc = subprocess .Popen (ps_aux_cmd , stdout = subprocess .PIPE )
668- grep_proc = subprocess .Popen (
669- grep_cmd , stdin = ps_aux_proc .stdout , stdout = subprocess .PIPE
670- )
671- exclude_grep_proc = subprocess .Popen (
672- grep_exclude_cmd , stdin = grep_proc .stdout , stdout = subprocess .PIPE
673- )
674-
675- ps_aux_proc .stdout .close ()
676- grep_proc .stdout .close ()
677-
678- output = exclude_grep_proc .communicate ()[0 ].decode ("utf-8" )
679-
680- for line in output .splitlines ():
681- try :
682- # Extract PID
683- pid = int (line .split ()[1 ])
684- subprocess .run (["kill" , "-15" , str (pid )], check = True )
685-
686- # Avoid zombies
687- try :
688- os .waitpid (pid , 0 )
689- except ChildProcessError :
690- pass
691- except Exception as e :
692- LogManager .logger .exception (
693- f"Failed to terminate process with line: { line } . Error: { e } "
694- )
695-
696- except Exception as e :
697- LogManager .logger .exception (
698- f"Failed to search and terminate processes with keyword '{ keyword } ': { e } "
699- )
700655
701656 def on_terminate_application (self , event ):
702657
@@ -713,15 +668,13 @@ def on_terminate_application(self, event):
713668 def on_terminate_tools (self , event ):
714669
715670 self .tools_launcher .terminate ()
716- self .terminate_harmonic_processes ()
717671
718672 def on_terminate_universe (self , event ):
719673
720674 if self .world_launcher != None :
721675 self .world_launcher .terminate ()
722676 if self .robot_launcher != None :
723677 self .robot_launcher .terminate ()
724- self .terminate_harmonic_processes ()
725678
726679 def on_disconnect (self , event ):
727680
@@ -755,8 +708,6 @@ def on_disconnect(self, event):
755708 except Exception as e :
756709 LogManager .logger .exception ("Exception terminating world launcher" )
757710
758- self .terminate_harmonic_processes ()
759-
760711 # Reiniciar el script
761712 python = sys .executable
762713 os .execl (python , python , * sys .argv )
@@ -864,7 +815,6 @@ def signal_handler(sign, frame):
864815 except Exception as e :
865816 LogManager .logger .exception ("Exception terminating world launcher" )
866817
867- self .terminate_harmonic_processes ()
868818 exit ()
869819
870820 signal .signal (signal .SIGINT , signal_handler )
0 commit comments