Skip to content
Snippets Groups Projects
Commit 6d30e84c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'track-requests' into 'master'

update _wait_4_free_slot and data in debug.log

See merge request !17
parents 5fe2de1a 50444af8
No related branches found
No related tags found
1 merge request!17update _wait_4_free_slot and data in debug.log
......@@ -33,6 +33,7 @@
# 2022-04-20 <axel.hahn@iml.unibe.ch> fix multiple domains using domain alias
# 2022-04-21 <axel.hahn@iml.unibe.ch> mix multiple domains using domain alias or not
# 2022-05-19 <axel.hahn@iml.unibe.ch> add timer and debug.log
# 2022-05-20 <axel.hahn@iml.unibe.ch> update _wait_4_free_slot and data in debug.log
# ======================================================================
......@@ -327,13 +328,7 @@ function _testUser(){
# param string(s) message
function _debuglog(){
if [ ${CM_writedebuglog} -eq 1 ]; then
local _sProcesses
typeset -i local _iProcesses
typeset -i local _iPos
_sProcesses=$( ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n )
_iProcesses=$( echo "$_sProcesses" | wc -l )
_iPos=$( echo "$_sProcesses" | grep -n " $$ " | head -1 | cut -f 1 -d ':' )
echo "$( date ) $CM_fqdn [$$] | $(show_timer) | pos $_iPos of $_iProcesses processes | $*" >> ${debuglogfile}
echo "$( date ) $CM_fqdn [$$] | $(show_timer) | $*" >> ${debuglogfile}
fi
}
......@@ -351,23 +346,28 @@ function _wait_for_free_slot(){
local _bWait=true
_debuglog "start in _wait_for_free_slot"
typeset -i local _iFirstPID=0
typeset -i local _iPos=0
local _sProcesses
sleep 3
_wd "--- Need to wait until own process PID $$ is on top ... "
while [ $_bWait = true ];
do
_sProcesses=$( ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n )
# _iFirstPID=$( ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n | head -1 | awk '{ print $2}' )
_iFirstPID=$( echo "$_sProcesses" | head -1 | awk '{ print $2}' )
_iPos=$( echo "$_sProcesses" | grep -n " $$ " | head -1 | cut -f 1 -d ':' )
_wd "instances: $_iProcesses"
test ${CM_showdebug} -ne 0 && echo "$_sProcesses"
if [ $_iFirstPID -eq $$ ]; then
# if [ $_iFirstPID -eq $$ ]; then
if [ $_iPos -eq 1 ]; then
_bWait=false
_debuglog "GO from _wait_for_free_slot"
_wd "OK. Go!"
else
_wd "- all instances"
_debuglog "waiting in _wait_for_free_slot"
# test ${CM_showdebug} && ps -ef | grep "bash.*$0" | grep -v "ssh.*@" | grep -v "grep" | sort -k 2 -n
test ${CM_showdebug} -ne 0 && echo "$_sProcesses"
_iProcesses=$( echo "$_sProcesses" | wc -l )
_iFirstPID=$( echo "$_sProcesses" | head -1 | awk '{ print $2}' )
_debuglog "zzz ... waiting in _wait_for_free_slot ... $_iFirstPID is first ... my pos is $_iPos of $_iProcesses"
sleep 10
fi
done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment