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 #cgi_getvars POST
if [ "$REQUEST" != "refresh" ]; then 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 echo "`date` - USER=$USER&REQUEST=$REQUEST&ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGE&MAINTAINERMODE=$MAINTAINERMODE" >> $LOG
fi fi
@ -340,10 +339,13 @@ if [ "$REQUEST" = "killtree" ]; then
killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes` killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes`
if [ "$killline" ]; then if [ "$killline" ]; then
if [ $KILLPID -ge 1 ]; then if [ $KILLPID -ge 1 ]; then
[ -e /proc/$KILLPID ] && $SUDO_WRAPPER killtree $KILLPID "$USER" if [ -e /proc/$KILLPID ]; then
set -- $killline $SUDO_WRAPPER killtree $KILLPID "$USER"
rm -f $5 else
sed -i "/^$KILLPID /d" $WEBBUILD_STATEDIR/processes set -- $killline
rm -f $5
sed -i "/^$KILLPID /d" $WEBBUILD_STATEDIR/processes
fi
else else
echo "<output>ERROR: Invalid PID</output>" echo "<output>ERROR: Invalid PID</output>"
fi fi
@ -379,6 +381,7 @@ if [ "$REQUEST" = "refresh" -o "$REQUEST" = "refreshjobs" ]; then
while read line; do while read line; do
set -- $line set -- $line
RETCODE=$6 RETCODE=$6
PROCESSLOG=$5
# if [ -e /proc/$1 -o $5 -lt 256 ]; then # if [ -e /proc/$1 -o $5 -lt 256 ]; then
numprocess=$(($numprocess + 1)) numprocess=$(($numprocess + 1))
cmdline=`echo $line | sed "s|$1 $2 $3 $4 $5 $RETCODE ||"` 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 [ "$STATE_JOBSSHOWALL" = "1" -o "$USER" = "$2" ] || continue
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; then 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...\">" 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 else
if [ $RETCODE -eq 256 ]; then
$SUDO_WRAPPER finishprocess $1 "$USER" $5
RETCODE=$?
fi
if [ $RETCODE -eq 0 ]; then if [ $RETCODE -eq 0 ]; then
# echo -n "<font color=lightgreen><b>OK</b></font>" # 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\">" 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 "\"<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 "REQUEST=showlog&LOGTYPE=processoutput&LOGFILE=$5\")>"
echo -n "<b><i>$cmdline</i></b>\"</a> (`date -r $5 +\"%F %T\"`)" 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 fi
if [ "$2" = "$USER" -o "$USER_ADMIN" ]; then if [ "$2" = "$USER" -o "$USER_ADMIN" ]; then
if [ $RETCODE -eq 256 -a -e /proc/$1 ]; 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" IMPORT_REPOSITORIES="$AUTOPORT_DEVEL_IMPORT_REPOSITORIES devel-$USER $AUTOPORT_DEVEL_RELEASE_REPOSITORIES"
fi fi
for f in $IMPORT_REPOSITORIES; do for f in $IMPORT_REPOSITORIES; do
[ "$f" = "$REPOSITORY" ] && continue # [ "$f" = "$REPOSITORY" ] && continue
if [ ! "$USER_ALLREPOSITORIES" ]; then if [ ! "$USER_ALLREPOSITORIES" ]; then
for u in $USER_CANMAINTAIN_REPOSITORIES devel-$USER; do for u in $USER_CANMAINTAIN_REPOSITORIES devel-$USER; do
[ "$u" = "$f" ] && echo -n "<option value=\"$f\">$f</option>" [ "$u" = "$f" ] && echo -n "<option value=\"$f\">$f</option>"