From 50ae9f489128d601010c5f608c4f7de1c7c27cbd Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Thu, 16 Dec 2021 20:58:24 +0100 Subject: [PATCH] Improve error messages from with-fuseki.sh The error message will now clarify that logs are dumped afterwards. Also dump only 15 lines of the fuseki logs by default when an error. --- with-fuseki.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/with-fuseki.sh b/with-fuseki.sh index 968cab709..ed58b68ce 100755 --- a/with-fuseki.sh +++ b/with-fuseki.sh @@ -20,13 +20,13 @@ wait_http_okay() { return 0 } kill -0 "${pid}" 2>/dev/null 1>&2 || { - 1>&2 echo "ERROR: pid ${pid} (${label}) not running anymore ..." + 1>&2 echo "ERROR: pid ${pid} (${label}) not running anymore, see log dump below for the possible cause." return 1 } 1>&2 echo "INFO: url ${url} (${label}) not okay, waiting ..." sleep 2 done - 1>&2 echo "ERROR: timed out trying to load ${url} (${label})" + 1>&2 echo "ERROR: timed out trying to load ${url} (${label}), see log dump below for the possible cause." return 1 } @@ -37,7 +37,7 @@ assert_pid_running() { done kill -0 "${pid}" 2>/dev/null 1>&2 || { - 1>&2 echo "ERROR: pid ${pid} (${label}) not running anymore ..." + 1>&2 echo "ERROR: pid ${pid} (${label}) not running anymore, see log dump below for the possible cause." return 1 } 1>&2 echo "INFO: pid ${pid} (${label}) running" @@ -87,12 +87,20 @@ exit_handler() { 1>&2 echo "WARNING: not killing fuseki fuseki_pid_normal=${fuseki_pid_normal} fuseki_pid_tdb=${fuseki_pid_tdb}" fi + local -a dump_cmd + if [ -n "${FUSEKI_DUMP_FULL_LOGS}" ] + then + dump_cmd=(cat) + else + dump_cmd=(tail -15) + fi + if [ -n "${FUSEKI_DUMP_LOGS}" ] || [ "${xrc}" != "0" ] then 1>&2 echo "dumping fuseki_log_normal=${fuseki_log_normal}" - cat "${fuseki_log_normal}" || : + "${dump_cmd[@]}" "${fuseki_log_normal}" || : 1>&2 echo "dumping fuseki_log_tdb=${fuseki_log_tdb}" - cat "${fuseki_log_tdb}" || : + "${dump_cmd[@]}" "${fuseki_log_tdb}" || : fi }