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

update _wait_4_free_slot and data in debug.log

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