[Qa-jenkins-scm] [jenkins.debian.net] 01/01: reproducible Debian: use Apache's NPH cgi mechanism to display growing logfiles. Thanks to Axel Beckert for telling me about NPH…

Holger Levsen holger at layer-acht.org
Tue May 2 14:52:45 UTC 2017


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit 1872900adf2df32858625955c5bf904d51823e57
Author: Holger Levsen <holger at layer-acht.org>
Date:   Tue May 2 16:52:27 2017 +0200

    reproducible Debian: use Apache's NPH cgi mechanism to display growing logfiles. Thanks to Axel Beckert for telling me about NPH…
    
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 bin/cgi-bin/nph-logwatch                           | 70 ++++++++++++++++++++++
 bin/reproducible_build_service.sh                  |  4 +-
 bin/reproducible_html_live_status.py               |  2 +-
 .../sites-available/jenkins.debian.net.conf        |  8 +++
 4 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/bin/cgi-bin/nph-logwatch b/bin/cgi-bin/nph-logwatch
new file mode 100755
index 0000000..e3e230e
--- /dev/null
+++ b/bin/cgi-bin/nph-logwatch
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+# Copyright © 2017 Holger Levsen (holger at layer-acht.org)
+# released under the GPLv=2
+
+set -e
+
+echo "HTTP/1.0 200 OK"
+echo "Connection: close"
+echo 'Content-type: text/plain; charset="utf-8"'
+echo ""
+
+TARGET=${QUERY_STRING}
+
+#
+# sanitize input
+#
+WORKER=$(basename $(dirname $TARGET))
+BUILD=$(basename $TARGET)
+
+#
+# we only work on known files…
+#
+DIR=/var/lib/jenkins/userContent/reproducible/debian/build_service/$WORKER
+FILE=$DIR/$BUILD/console.log
+
+# keep commented code for debugging…
+if [ ! -d $DIR ] ; then
+	echo "$DIR does not exist."
+	#echo "Wanted $TARGET but $DIR does not exist."
+	exit 0
+elif [ ! -f $FILE ] ; then
+	echo "$FILE does not exist."
+	#echo "Wanted $TARGET but $FILE does not exist."
+	exit 0
+fi
+
+#
+# this build exists, what about this one:
+#
+let NEW_BUILD=$BUILD+1
+
+#
+# if this ain't the latest build, just cat it's logfile
+#
+if [ -e $DIR/$NEW_BUILD/console.log ] ; then
+	cat $FILE
+#
+# if the worker ain't running, just cat the logfile
+#
+elif [ ! -z "$(ps fax|grep -v grep|grep 'reproducible_worker $WORKER.sh ')" ] ; then
+	cat $FILE
+#
+# FIXME: we should really just convert 'latest' into a number here and use the tail below… 
+#
+elif [ "$BUILD" = "latest" ] ; then
+	cat $FILE
+else
+	#
+	# else, we tail the logfile and kill the tail process, once the next build
+	# has been started
+	#
+	tail -c +0 -f $FILE &
+	TAILPID=$!
+	while ! test -f $DIR/$NEW_BUILD/console.log ; do
+		sleep 1
+	done
+	kill -9 $TAILPID
+fi
+echo 
diff --git a/bin/reproducible_build_service.sh b/bin/reproducible_build_service.sh
index 9d0539e..7d457c5 100755
--- a/bin/reproducible_build_service.sh
+++ b/bin/reproducible_build_service.sh
@@ -257,8 +257,8 @@ while true ; do
 done
 
 # FIXME: TODO left for _service.sh:
-# * logs should auto display in browser like with jenkins… (long-polling, meta-refresh, something)
-#   - there's an NPH solution pointed out by Xtaran
+# * logs should auto display in browser like with jenkins…
+#   - mostly done, except one needs to manually scroll down… (could probably be fixed with javascript…)
 # * enabling the service in update_jdn
 # * maintenance job might want to:
 #   - check for running builds using systemctl show & ps fax
diff --git a/bin/reproducible_html_live_status.py b/bin/reproducible_html_live_status.py
index ac91e76..65c25cf 100755
--- a/bin/reproducible_html_live_status.py
+++ b/bin/reproducible_html_live_status.py
@@ -149,7 +149,7 @@ def generate_live_status_table(arch):
         html += '<td><code>' + link_package(pkg, suite, arch) + '</code></td>'
         html += '<td>' + str(row[4]) + '</td><td>' + str(row[5]) + '</td>'
         html += '<td>' + convert_into_status_html(str(row[6])) + '</td><td>' + duration + '</td><td>' + avg_duration + '</td>'
-        html += '<td><a href="https://jenkins.debian.net/userContent/reproducible/debian/build_service/' + str(row[9]) + '/console.log">' + str(row[9]) + '</a></td>'
+        html += '<td><a href="https://jenkins.debian.net/cgi-bin/nph-logwatch?' + str(row[9]) + '">' + str(row[9]) + '</a></td>'
         html += '</tr>\n'
     html += '</table></p>\n'
     return html
diff --git a/hosts/jenkins/etc/apache2/sites-available/jenkins.debian.net.conf b/hosts/jenkins/etc/apache2/sites-available/jenkins.debian.net.conf
index 9310e20..80fd7ce 100644
--- a/hosts/jenkins/etc/apache2/sites-available/jenkins.debian.net.conf
+++ b/hosts/jenkins/etc/apache2/sites-available/jenkins.debian.net.conf
@@ -330,6 +330,14 @@ Use common-debian-service-https-redirect www.reproducible-builds.org
 	RewriteCond %{REQUEST_URI} ^/debian(/|)$
 	RewriteRule ^/?(.*) /debian/reproducible.html [R,L]
 
+	# for watching service logfiles
+	ScriptAlias /cgi-bin /srv/jenkins/bin/cgi-bin
+	<Directory "/srv/jenkins/bin/cgi-bin">
+	    AllowOverride None
+	    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
+	    Require all granted
+	</Directory>
+
 	<Proxy *>
 		Require all granted
 	</Proxy>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list