Skip to content

Instantly share code, notes, and snippets.

@kozakana
Created February 3, 2020 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kozakana/9509a964db2380ebb045f584708f4457 to your computer and use it in GitHub Desktop.
Save kozakana/9509a964db2380ebb045f584708f4457 to your computer and use it in GitHub Desktop.
Send USR1 signal to shoryuken processes that did not terminate
#!/bin/sh
pid_files=("$@")
correct_pids=()
if [ ${#pid_files[@]} -le 0 ]; then
echo "Usage: ./shoryuken_process_clean.sh PID_FILE..."
exit 1
fi
for ((idx=0; idx<${#pid_files[@]}; idx++)) do
correct_pids+=(`cat ${pid_files[$idx]}`)
done
exist_pid() {
for ((j=0; j<${#correct_pids[@]}; j++)) do
if [ ${correct_pids[$j]} -eq $1 ]; then
true
return
fi
done
false
}
active_pids=(`ps aux | awk '$11 == "ruby" && $12 ~ /shoryuken$/ {print $2}'`)
for ((i=0; i<${#active_pids[@]}; i++)) do
exist_pid ${active_pids[i]}
if [ $? -eq 1 ]; then
kill -USR1 ${active_pids[i]}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment