webbuild: fixes in processes list management

This commit is contained in:
Silvan Calarco 2014-02-01 14:56:17 +01:00
parent aee7f737b1
commit d73319d4ea

View File

@ -15,7 +15,6 @@ cgi_getvars BOTH ALL
#cgi_getvars POST
if [ "$REQUEST" != "refresh" ]; then
# echo "`date` - $QUERY_STRING_POST" >> $LOG
echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi
@ -340,10 +339,13 @@ if [ "$REQUEST" = "killtree" ]; then
killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes`
if [ "$killline" ]; then
if [ $KILLPID -ge 1 ]; then
[ -e /proc/$KILLPID ] && $SUDO_WRAPPER killtree $KILLPID "$USER"
set -- $killline
rm -f $5
sed -i "/^$KILLPID /d" $WEBBUILD_STATEDIR/processes
if [ -e /proc/$KILLPID ]; then
$SUDO_WRAPPER killtree $KILLPID "$USER"
else
set -- $killline
rm -f $5
sed -i "/^$KILLPID /d" $WEBBUILD_STATEDIR/processes
fi
else
echo "<output>ERROR: Invalid PID</output>"
fi
@ -379,6 +381,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
while read line; do
set -- $line
RETCODE=$6
PROCESSLOG=$5
# if [ -e /proc/$1 -o $5 -lt 256 ]; then
numprocess=$(($numprocess + 1))
cmdline=`echo $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"`
@ -398,7 +401,14 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
[ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" width=10 height=10 src=\"/images/inprogress.gif\" alt=\"running...\" title=\"running...\">"
elif [ ! -e $PROCESSLOG ]; then
sed -i "/$1 $USER.* $PROCESSLOG /d" $WEBBUILD_STATEDIR/processes
continue
else
if [ $RETCODE -eq 256 ]; then
$SUDO_WRAPPER finishprocess $1 "$USER" $5
RETCODE=$?
fi
if [ $RETCODE -eq 0 ]; then
# echo -n "<font color=lightgreen><b>OK</b></font>"
echo -n "<img style=\"margin-top:-1px;margin-right:2px;\" src=\"/images/ok.png\" width=10 height=10 alt=\"OK\" title=\"Job successfully completed\">"
@ -416,10 +426,6 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
echo -n "\"<a href=# title=\"Click to see output log\" onClick=ajax_getvalues(\"ENVIRONMENT=$3&PACKAGE=$PACKAGE_ENCODED&"
echo -n "REQUEST=showlog&LOGTYPE=processoutput&LOGFILE=$5\")>"
echo -n "<b><i>$cmdline</i></b>\"</a> (`date -r $5 +\"%F %T\"`)"
if [ $RETCODE -eq 256 ]; then
$SUDO_WRAPPER finishprocess $1 "$USER" $5
RETCODE=$?
fi
fi
if [ "$2" = "$USER" -o "$USER_ADMIN" ]; then
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then
@ -2131,7 +2137,7 @@ if [ "$MAINTAINERMODE" = "true" ]; then
IMPORT_REPOSITORIES="$AUTOPORT_DEVEL_IMPORT_REPOSITORIES devel-$USER $AUTOPORT_DEVEL_RELEASE_REPOSITORIES"
fi
for f in $IMPORT_REPOSITORIES; do
[ "$f" = "$REPOSITORY" ] && continue
# [ "$f" = "$REPOSITORY" ] && continue
if [ ! "$USER_ALLREPOSITORIES" ]; then
for u in $USER_CANMAINTAIN_REPOSITORIES devel-$USER; do
[ "$u" = "$f" ] && echo -n "<option value=\"$f\">$f</option>"