-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Making a commit to improve on the existing script to kill TagUI processes. For eg if Ctrl+C is used to kill TagUI prematurely, TagUI main process would lose the control to do clean-up of integrations (SikuliX, R, Python, Chrome) and Chrome browser. This shell script (for all the 3 OSes) will kill those processes to free up memory and allows TagUI to start running from a clean state. These actions are not done by default when TagUI is launched, as it is expected that TagUI exits cleanly. Otherwise cleaning up all processes by default will hide potential issues should they arise and they will end up not getting reported.
- Loading branch information
Showing
2 changed files
with
106 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,59 @@ | ||
#!/usr/bin/env bash | ||
# TO KILL INTEGRATION PROCESSES IF CTRL+C WAS USED TO QUIT TAGUI PREMATURELY ~ TEBEL.ORG # | ||
# TO MANUALLY KILL TAGUI PROCESSES, EG IF CTRL+C WAS USED TO QUIT TAGUI ~ TEBEL.ORG # | ||
|
||
# checking for existence of files before sending finish signal is important | ||
# otherwise for ongoing tagui iterations, all integrations will be invoked | ||
# aggressive failsafe for tagui and friends that have not exited gracefully | ||
# works by scanning processes for tagui keywords and killing them one by one | ||
|
||
if [ -f "tagui_r/tagui_r.in" ]; then echo "finish" > tagui_r/tagui_r.in; fi | ||
if [ -f "tagui_py/tagui_py.in" ]; then echo "finish" > tagui_py/tagui_py.in; fi | ||
if [ -f "tagui.sikuli/tagui_sikuli.in" ]; then echo "finish" > tagui.sikuli/tagui_sikuli.in; fi | ||
if [ -f "tagui_chrome.in" ]; then echo "finish" > tagui_chrome.in; fi | ||
while true; do | ||
php_process_id="$(ps -x | grep tagui_chrome\.php | grep -v 'grep tagui_chrome\.php' | sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$php_process_id" ]; then | ||
kill $php_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
while true; do | ||
chrome_process_id="$(ps -x | grep remote-debugging-port=9222 | grep tagui_user_profile | sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$chrome_process_id" ]; then | ||
kill $chrome_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
while true; do | ||
sikuli_process_id="$(ps -x | grep tagui\.sikuli | grep -v 'grep tagui\.sikuli'| sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$sikuli_process_id" ]; then | ||
kill $sikuli_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
while true; do | ||
python_process_id="$(ps -x | grep tagui_py\.py | grep -v 'grep tagui_py\.py'| sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$python_process_id" ]; then | ||
kill $python_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
while true; do | ||
r_process_id="$(ps -x | grep tagui_r\.R | grep -v 'grep tagui_r\.R'| sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$r_process_id" ]; then | ||
kill $r_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done | ||
|
||
while true; do | ||
tagui_process_id="$(ps -x | grep /tagui/src | grep -v 'grep /tagui/src'| sed -e 's/^[ ]*//' | cut -d' ' -f 1 | sort -nur | head -n 1)" | ||
if [ -n "$tagui_process_id" ]; then | ||
kill $tagui_process_id > /dev/null 2>&1 | ||
else | ||
break | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,50 @@ | ||
@echo off | ||
rem # TO KILL INTEGRATION PROCESSES IF CTRL+C WAS USED TO QUIT TAGUI PREMATURELY ~ TEBEL.ORG # | ||
|
||
rem checking for existence of files before sending finish signal is important | ||
rem otherwise for ongoing tagui iterations, all integrations will be invoked | ||
|
||
if exist "tagui_r\tagui_r.in" echo finish > tagui_r\tagui_r.in | ||
if exist "tagui_py\tagui_py.in" echo finish > tagui_py\tagui_py.in | ||
if exist "tagui.sikuli\tagui_sikuli.in" echo finish > tagui.sikuli\tagui_sikuli.in | ||
if exist "tagui_chrome.in" echo finish > tagui_chrome.in | ||
@echo off | ||
rem # TO MANUALLY KILL TAGUI PROCESSES, EG IF CTRL+C WAS USED TO QUIT TAGUI ~ TEBEL.ORG # | ||
|
||
rem aggressive failsafe for tagui and friends that have not exited gracefully | ||
rem works by scanning processes for tagui keywords and killing them one by one | ||
|
||
rem set path to unix utilities for windows command prompt | ||
if exist "%~dp0unx\gawk.exe" set "path=%~dp0unx;%path%" | ||
|
||
:repeat_kill_php | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "caption like '%%php.exe%%' and commandline like '%%tagui_chrome.php%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set php_process_id=%%p | ||
if not "%php_process_id%"=="" ( | ||
taskkill /PID %php_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_php | ||
) | ||
|
||
:repeat_kill_chrome | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "caption like '%%chrome.exe%%' and commandline like '%%tagui_user_profile --remote-debugging-port=9222%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set chrome_process_id=%%p | ||
if not "%chrome_process_id%"=="" ( | ||
taskkill /PID %chrome_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_chrome | ||
) | ||
|
||
:repeat_kill_sikuli | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "commandline like '%%tagui.sikuli%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set sikuli_process_id=%%p | ||
if not "%sikuli_process_id%"=="" ( | ||
taskkill /PID %sikuli_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_sikuli | ||
) | ||
|
||
:repeat_kill_python | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "commandline like '%%tagui_py.py%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set python_process_id=%%p | ||
if not "%python_process_id%"=="" ( | ||
taskkill /PID %python_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_python | ||
) | ||
|
||
:repeat_kill_r | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "commandline like '%%tagui_r.R%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set r_process_id=%%p | ||
if not "%r_process_id%"=="" ( | ||
taskkill /PID %r_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_r | ||
) | ||
|
||
:repeat_kill_tagui | ||
for /f "tokens=* usebackq" %%p in (`wmic process where "executablepath like '%%\\tagui\\src\\%%' and not caption like '%%cut.exe%%' and not caption like '%%sort.exe%%' and not caption like '%%head.exe%%'" get processid 2^>nul ^| cut -d" " -f 1 ^| sort -nur ^| head -n 1`) do set tagui_process_id=%%p | ||
if not "%tagui_process_id%"=="" ( | ||
taskkill /PID %tagui_process_id% /T /F > nul 2>&1 | ||
goto repeat_kill_tagui | ||
) |